Soenneker.ServiceBus.Receptor 4.0.2067

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

An abstract Azure Service Bus queue processor that provisions its queue, dispatches body and type data to a derived receptor, and completes successfully handled messages.

Installation

dotnet add package Soenneker.ServiceBus.Receptor

Implement a receptor

Derive from ServiceBusReceptor, choose the queue in the base constructor, and implement the application handler:

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Soenneker.ServiceBus.Client.Abstract;
using Soenneker.ServiceBus.Queue.Abstract;
using Soenneker.ServiceBus.Receptor;

public sealed class OrderReceptor : ServiceBusReceptor
{
    public OrderReceptor(
        ILogger<ServiceBusReceptor> logger,
        IServiceBusClientUtil clientUtil,
        IServiceBusQueueUtil queueUtil,
        IConfiguration configuration)
        : base("orders", logger, clientUtil, queueUtil, configuration)
    {
    }

    public override async ValueTask OnMessageReceived(
        string messageContent,
        string type,
        CancellationToken cancellationToken = default)
    {
        switch (type)
        {
            case "order.created.v1":
                await HandleOrderCreated(messageContent, cancellationToken);
                break;
            default:
                throw new NotSupportedException($"Unsupported message type: {type}");
        }
    }
}

The body is supplied as a string. The type comes from the Service Bus message's ApplicationProperties["type"] value and is expected to be a non-empty string. Producers using Soenneker.ServiceBus.Message receive this property automatically.

Register and start

The base registrar adds queue, administration, and client dependencies; it cannot register your abstract-derived type for you:

using Soenneker.ServiceBus.Receptor.Registrars;

services.AddServiceBusReceptorAsSingleton();
services.AddSingleton<OrderReceptor>();

Resolve the receptor during application startup and initialize it once:

OrderReceptor receptor = services.GetRequiredService<OrderReceptor>();
await receptor.Init(cancellationToken);

Simply registering the receptor does not start it. Init creates the queue with Azure defaults when absent, creates a processor, attaches handlers, and starts processing. The connection-string credential therefore needs both queue-management and receive permissions.

Registering the base dependencies as scoped is also supported with AddServiceBusReceptorAsScoped(). The scoped queue utility retains singleton administration and data-plane clients.

Processing and settlement

The processor uses peek-lock mode, disables automatic completion, and handles one message at a time. After OnMessageReceived completes successfully, the receptor explicitly completes the message.

If the handler or completion throws, the exception flows back to the Azure processor and the message is not completed by this class. Configure queue retry and dead-letter behavior for your workload, and make handlers idempotent because a message may be delivered again.

Azure:ServiceBus:Log=true enables full message-body logging at debug level. Bodies may contain credentials or personal data, so leave this disabled unless the log destination and retention policy are suitable. Information logs identify the queue and message type without recording the body.

Dispose the receptor during application shutdown. Disposal stops processing, removes its event handlers, and disposes the processor; it 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 (3)

Showing the top 3 NuGet packages that depend on Soenneker.ServiceBus.Receptor:

Package Downloads
Soenneker.ServiceBus.Suite

Convenience references and dependency injection registration for the Soenneker Service Bus transmitter stack.

Soenneker.ServiceBus.Receptors.MsTeams

Consumes Microsoft Teams queue messages and enqueues deserialized payloads for Hangfire-backed webhook delivery.

Soenneker.ServiceBus.Receptors.Email

Consumes email queue messages and enqueues their raw body and type for Hangfire-backed email processing.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.2070 107 9/25/2026
4.0.2069 75 9/25/2026
4.0.2068 58 9/25/2026
4.0.2067 75 9/25/2026
4.0.2066 59 9/25/2026
4.0.2065 53 9/25/2026
4.0.2064 78 9/24/2026
4.0.2063 76 9/24/2026
4.0.2062 390 9/16/2026
4.0.2061 146 9/16/2026
4.0.2060 143 9/16/2026
4.0.2059 136 9/16/2026
4.0.2058 129 9/15/2026
4.0.2057 242 9/13/2026
4.0.2056 143 9/13/2026
4.0.2055 124 9/13/2026
4.0.2054 105 9/13/2026
4.0.2053 110 9/13/2026
4.0.2052 117 9/13/2026
4.0.2051 193 9/13/2026
Loading failed

Updated Soenneker.ServiceBus.Queue to 4.0.2408