Soenneker.ServiceBus.Message
4.0.3083
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.ServiceBus.Message --version 4.0.3083
NuGet\Install-Package Soenneker.ServiceBus.Message -Version 4.0.3083
<PackageReference Include="Soenneker.ServiceBus.Message" Version="4.0.3083" />
<PackageVersion Include="Soenneker.ServiceBus.Message" Version="4.0.3083" />
<PackageReference Include="Soenneker.ServiceBus.Message" />
paket add Soenneker.ServiceBus.Message --version 4.0.3083
#r "nuget: Soenneker.ServiceBus.Message, 4.0.3083"
#:package Soenneker.ServiceBus.Message@4.0.3083
#addin nuget:?package=Soenneker.ServiceBus.Message&version=4.0.3083
#tool nuget:?package=Soenneker.ServiceBus.Message&version=4.0.3083
Soenneker.ServiceBus.Message
Builds Azure ServiceBusMessage instances from Soenneker.Messages.Base.Message payloads with serializer selection, type metadata, size rejection, and optional payload logging.
Installation
dotnet add package Soenneker.ServiceBus.Message
Registration
using Soenneker.ServiceBus.Message.Registrars;
services.AddServiceBusMessageUtilAsSingleton();
The utility is stateless after configuration is loaded. A scoped registration is also available through AddServiceBusMessageUtilAsScoped().
Build and send a message
Define a transport payload derived from Soenneker.Messages.Base.Message, then pass its stable type identifier to BuildMessage:
using Azure.Messaging.ServiceBus;
using Soenneker.Messages.Base;
using Soenneker.ServiceBus.Message.Abstract;
public sealed class OrderCreated : Message
{
public required string OrderId { get; init; }
}
OrderCreated payload = new()
{
Type = "order.created.v1",
Id = Guid.NewGuid().ToString("N"),
Queue = "orders",
Sender = "checkout-api",
CreatedAt = DateTimeOffset.UtcNow,
OrderId = orderId
};
ServiceBusMessage? transportMessage =
messageUtil.BuildMessage(payload, payload.Type);
if (transportMessage is null)
return;
await sender.SendMessageAsync(transportMessage, cancellationToken);
The type argument is placed in ApplicationProperties["type"]. It is independent of payload.Type, so pass the same stable value unless your routing contract deliberately requires something else.
This builder does not map payload.Id to ServiceBusMessage.MessageId, set ContentType, choose a queue, or send the message. Set additional broker properties on the returned message before sending when required.
Serialization and size behavior
System.Text.Json is used by default. Set the payload's NewtonsoftSerialize property to true to use Newtonsoft.Json instead:
payload.NewtonsoftSerialize = true;
Messages whose serialized body exceeds 260,096 bytes are rejected and return null. That check covers the body only; it does not calculate the broker size of application properties or other AMQP overhead.
Serialization failures are logged at critical level and return null. Always check the result before passing it to a sender.
Payload logging
Azure:ServiceBus:Log controls payload logging:
{
"Azure": {
"ServiceBus": {
"Log": false
}
}
}
When enabled, complete serialized payloads are written at debug level during normal message construction and may be included in critical error logs. It also selects the pretty JSON option instead of the web JSON option, so enabling it changes whitespace in the serialized body.
Leave payload logging disabled for messages containing credentials, personal data, or other sensitive fields unless the log destination and retention policy are appropriate.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Azure.Messaging.ServiceBus (>= 7.20.2)
- Soenneker.Extensions.Configuration (>= 4.0.869)
- Soenneker.Messages.Base (>= 4.0.1169)
- Soenneker.Utils.Json (>= 4.0.2663)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Soenneker.ServiceBus.Message:
| Package | Downloads |
|---|---|
|
Soenneker.ServiceBus.Transmitter
A utility library for sending Service Bus messages |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.3093 | 0 | 9/1/2026 |
| 4.0.3092 | 0 | 9/1/2026 |
| 4.0.3091 | 0 | 8/31/2026 |
| 4.0.3089 | 0 | 8/31/2026 |
| 4.0.3088 | 0 | 8/31/2026 |
| 4.0.3087 | 0 | 8/31/2026 |
| 4.0.3085 | 0 | 8/31/2026 |
| 4.0.3084 | 0 | 8/31/2026 |
| 4.0.3083 | 0 | 8/31/2026 |
| 4.0.3082 | 27 | 8/31/2026 |
| 4.0.3081 | 47 | 8/31/2026 |
| 4.0.3080 | 38 | 8/31/2026 |
| 4.0.3079 | 43 | 8/31/2026 |
| 4.0.3078 | 33 | 8/30/2026 |
| 4.0.3077 | 72 | 8/30/2026 |
| 4.0.3076 | 28 | 8/30/2026 |
| 4.0.3075 | 149 | 8/30/2026 |
| 4.0.3074 | 37 | 8/30/2026 |
| 4.0.3073 | 35 | 8/30/2026 |
| 4.0.3071 | 171 | 8/30/2026 |
Update dependency Soenneker.Utils.Json to 4.0.2663 (#3945)