Skip to content

Commit 5ea9fd1

Browse files
authored
Added record types to immutable messages
1 parent 787b929 commit 5ea9fd1

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

nservicebus/messaging/immutable-messages.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Immutable Messages
3-
reviewed: 2024-08-13
3+
reviewed: 2025-02-19
44
component: Core
55
related:
66
- samples/immutable-messages
@@ -13,8 +13,19 @@ Usually messages are designed as [DTOs](https://en.wikipedia.org/wiki/Data_trans
1313
1414
Message objects can be made immutable at runtime by:
1515

16-
1. Creating properties with only public getters and initializing these properties via constructor initialization.
17-
2. Having regular message classes with public getters/setters at the sender, where these classes implement an interface with only public getters. Receivers reference only the interface.
16+
1. Using record types
17+
2. Creating properties with only public getters and initializing these properties via constructor initialization.
18+
3. Having regular message classes with public getters/setters at the sender, where these classes implement an interface with only public getters. Receivers reference only the interface.
19+
20+
21+
## Record types
22+
23+
> [!NOTE]
24+
> Record types are supported since NServiceBus 9
25+
26+
```c#
27+
public record CancelOrder(int OrderId);
28+
```
1829

1930
## Properties with only public getters
2031

0 commit comments

Comments
 (0)