Soenneker.ServiceBus.Message 11.0.3228

Prefix Reserved
dotnet add package Soenneker.ServiceBus.Message --version 11.0.3228
                    
NuGet\Install-Package Soenneker.ServiceBus.Message -Version 11.0.3228
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.ServiceBus.Message" Version="11.0.3228" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.ServiceBus.Message" Version="11.0.3228" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.ServiceBus.Message" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.ServiceBus.Message --version 11.0.3228
                    
#r "nuget: Soenneker.ServiceBus.Message, 11.0.3228"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soenneker.ServiceBus.Message@11.0.3228
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.ServiceBus.Message&version=11.0.3228
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.ServiceBus.Message&version=11.0.3228
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

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

Messages are serialized using System.Text.Json.

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 Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
11.0.3228 48 11/14/2026
11.0.3226 252 11/11/2026
11.0.3225 178 11/11/2026
11.0.3224 143 11/11/2026
11.0.3223 114 11/11/2026
11.0.3222 64 11/11/2026
11.0.3221 62 11/11/2026
11.0.3219 56 11/11/2026
11.0.3218 326 11/10/2026
11.0.3217 111 11/10/2026
11.0.3216 545 11/3/2026
11.0.3215 173 11/3/2026
11.0.3214 228 11/3/2026
11.0.3212 152 11/3/2026
11.0.3211 174 11/3/2026
11.0.3210 171 11/3/2026
11.0.3209 183 11/2/2026
11.0.3208 387 10/29/2026
11.0.3207 310 10/27/2026
11.0.3206 435 10/27/2026
Loading failed

Update dependency Soenneker.Utils.Json to 11.0.2789 (#4123)