Soenneker.ServiceBus.Sender 4.0.2532

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.2532
                    
NuGet\Install-Package Soenneker.ServiceBus.Sender -Version 4.0.2532
                    
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.2532" />
                    
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.2532" />
                    
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.2532
                    
#r "nuget: Soenneker.ServiceBus.Sender, 4.0.2532"
                    
#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.2532
                    
#: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.2532
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.ServiceBus.Sender&version=4.0.2532
                    
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.2542 149 10/1/2026
4.0.2541 65 10/1/2026
4.0.2540 242 9/30/2026
4.0.2539 515 9/29/2026
4.0.2538 104 9/29/2026
4.0.2537 71 9/29/2026
4.0.2535 69 9/29/2026
4.0.2534 70 9/29/2026
4.0.2533 450 9/25/2026
4.0.2532 95 9/25/2026
4.0.2531 88 9/25/2026
4.0.2530 86 9/25/2026
4.0.2529 88 9/25/2026
4.0.2528 84 9/25/2026
4.0.2527 91 9/25/2026
4.0.2526 576 9/24/2026
4.0.2525 91 9/24/2026
4.0.2524 1,113 9/16/2026
4.0.2523 206 9/16/2026
4.0.2522 184 9/16/2026
Loading failed

Updated Soenneker.ServiceBus.Queue to 4.0.2410