Configure Formatters¶
All publishers and subscribers require an IDataFormatter implementation.
Formatters are responsible for:
- serialization;
- deserialization;
- payload conversion.
Available Implementations¶
Current implementations include:
| Package | Serializer |
|---|---|
| ServiceBus.Formatters.Ms | System.Text.Json |
| ServiceBus.Formatters.Newtonsoft | Newtonsoft.Json |
Formatter Architecture¶
graph LR
Message
IDataFormatter
Payload
Message --> IDataFormatter
IDataFormatter --> Payload
Microsoft Formatter¶
Install package:
dotnet add package ServiceBus.Formatters.Ms
Provides serialization based on:
System.Text.Json
Newtonsoft Formatter¶
Install package:
dotnet add package ServiceBus.Formatters.Newtonsoft
Provides serialization based on:
Newtonsoft.Json
Selection Guidelines¶
Choose Microsoft formatter when:
- performance is important;
- System.Text.Json features are sufficient.
Choose Newtonsoft formatter when:
- advanced serialization features are required;
- legacy applications already depend on Newtonsoft.Json.
Next Step¶
Once a formatter has been configured, publishers and subscribers can be constructed using descriptors.