Soenneker.ServiceBus.Message 4.0.3078

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.ServiceBus.Message --version 4.0.3078
                    
NuGet\Install-Package Soenneker.ServiceBus.Message -Version 4.0.3078
                    
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="4.0.3078" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.ServiceBus.Message" Version="4.0.3078" />
                    
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 4.0.3078
                    
#r "nuget: Soenneker.ServiceBus.Message, 4.0.3078"
                    
#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@4.0.3078
                    
#: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=4.0.3078
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.ServiceBus.Message&version=4.0.3078
                    
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

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 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. 
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
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
4.0.3070 39 8/30/2026
4.0.3069 51 8/30/2026
Loading failed

Harden Service Bus message logging