Soenneker.ServiceBus.Sender 4.0.2502

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

Creates and caches one Azure ServiceBusSender per queue while reusing the shared top-level ServiceBusClient.

Installation

dotnet add package Soenneker.ServiceBus.Sender

Configuration and registration

Provide Azure:ServiceBus:ConnectionString, then choose the sender-cache lifetime:

using Soenneker.ServiceBus.Sender.Registrars;

services.AddServiceBusSenderUtilAsScoped();

The scoped registration intentionally keeps the queue, administration, and top-level client utilities singleton. Disposing a scope releases that scope's cached senders while the shared ServiceBusClient remains available. Use AddServiceBusSenderUtilAsSingleton() when sender instances should remain cached for the entire application lifetime.

Because the first Get for a queue calls CreateQueueIfDoesNotExist, the connection-string credential needs queue-management permission in addition to send permission.

Send to a queue

using Azure.Messaging.ServiceBus;
using Soenneker.ServiceBus.Sender.Abstract;

public sealed class OrderPublisher(IServiceBusSenderUtil senderUtil)
{
    public async Task Send(
        BinaryData body,
        CancellationToken cancellationToken)
    {
        ServiceBusSender sender =
            await senderUtil.Get("orders", cancellationToken);

        var message = new ServiceBusMessage(body)
        {
            ContentType = "application/json",
            MessageId = Guid.NewGuid().ToString("N")
        };

        message.ApplicationProperties["type"] = "order.created.v1";

        await sender.SendMessageAsync(message, cancellationToken);
    }
}

The first request for an exact queue-name key ensures the queue exists, gets the shared client, and creates a sender. Later requests for that key reuse the same sender. Different queue-name strings receive different cached senders.

The utility does not build message bodies, set broker properties, batch messages, schedule delivery, or retry application-level failures. Use Soenneker.ServiceBus.Message when its message-envelope convention fits your producer.

Do not dispose a sender returned by Get; the sender utility owns it. Disposing the scoped or singleton utility disposes every sender it created but does not dispose the shared top-level Service Bus client.

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.Sender:

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.2524 0 9/16/2026
4.0.2523 0 9/16/2026
4.0.2522 0 9/16/2026
4.0.2521 0 9/16/2026
4.0.2520 0 9/16/2026
4.0.2519 31 9/16/2026
4.0.2518 43 9/16/2026
4.0.2517 61 9/15/2026
4.0.2516 481 9/13/2026
4.0.2515 78 9/13/2026
4.0.2514 146 9/13/2026
4.0.2513 80 9/13/2026
4.0.2512 114 9/13/2026
4.0.2511 79 9/13/2026
4.0.2510 88 9/13/2026
4.0.2509 333 9/13/2026
4.0.2508 82 9/13/2026
4.0.2507 379 9/12/2026
4.0.2506 167 9/12/2026
4.0.2502 90 9/9/2026
Loading failed

Updated Soenneker.ServiceBus.Queue to 4.0.2384