Soenneker.ServiceBus.Sender 4.0.2529

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.2529
                    
NuGet\Install-Package Soenneker.ServiceBus.Sender -Version 4.0.2529
                    
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.2529" />
                    
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.2529" />
                    
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.2529
                    
#r "nuget: Soenneker.ServiceBus.Sender, 4.0.2529"
                    
#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.2529
                    
#: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.2529
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.ServiceBus.Sender&version=4.0.2529
                    
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.2571 0 10/15/2026
4.0.2570 0 10/15/2026
4.0.2569 0 10/14/2026
4.0.2568 21 10/14/2026
4.0.2567 30 10/14/2026
4.0.2566 51 10/14/2026
4.0.2565 43 10/14/2026
4.0.2564 44 10/14/2026
4.0.2563 44 10/14/2026
4.0.2556 109 10/13/2026
4.0.2555 71 10/13/2026
4.0.2552 182 10/12/2026
4.0.2551 79 10/12/2026
4.0.2550 77 10/12/2026
4.0.2549 82 10/12/2026
4.0.2548 87 10/11/2026
4.0.2547 87 10/11/2026
4.0.2546 87 10/11/2026
4.0.2545 76 10/11/2026
4.0.2529 96 9/25/2026
Loading failed

Updated Soenneker.ServiceBus.Queue to 4.0.2408