ServiceBus.Core.Rabbit 3.9.0

dotnet add package ServiceBus.Core.Rabbit --version 3.9.0
                    
NuGet\Install-Package ServiceBus.Core.Rabbit -Version 3.9.0
                    
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="ServiceBus.Core.Rabbit" Version="3.9.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ServiceBus.Core.Rabbit" Version="3.9.0" />
                    
Directory.Packages.props
<PackageReference Include="ServiceBus.Core.Rabbit" />
                    
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 ServiceBus.Core.Rabbit --version 3.9.0
                    
#r "nuget: ServiceBus.Core.Rabbit, 3.9.0"
                    
#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 ServiceBus.Core.Rabbit@3.9.0
                    
#: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=ServiceBus.Core.Rabbit&version=3.9.0
                    
Install as a Cake Addin
#tool nuget:?package=ServiceBus.Core.Rabbit&version=3.9.0
                    
Install as a Cake Tool

ServiceBus.Core.Rabbit 3.x

The RabbitMQ implementation of ServiceBus.Core, built on RabbitMQ.Client 6.x (IModel, synchronous). This is the legacy line: it stays supported for the applications that have not moved to RabbitMQ.Client 7, whose 6.x line RabbitMQ has declared end of life. For the new line see ServiceBus.Core.Rabbit 4.x, which has the same package id and the same namespaces.

dotnet add package ServiceBus.Core.Rabbit --version 3.*
dotnet add package ServiceBus.Formatters.Newtonsoft   # or ServiceBus.Formatters.Ms

Targets: net8.0, net9.0, net10.0. netstandard2.1 and net6.0 are no longer targets: applications on them stay on the earlier releases.

A publisher and a subscriber

var connectionFactory = new ConnectionFactory
{
    Uri = new Uri("amqp://guest:guest@localhost:5672"),
    DispatchConsumersAsync = true                    // required by the subscribers
};

IDataFormatter formatter = new JsonDataFormatter(new JsonSerializerSettings(), Encoding.UTF8);

// owns every channel and connection it builds, and closes them when it is disposed
await using var channels = new ChannelFactory(connectionFactory);

var queue = new QueueBoundDescriptor { Name = "orders", Durable = true, AutoDelete = false, Binder = { RoutingKey = "created" } };

var publisherDescriptor = new PublisherBoundDescriptor
{
    Exchanges = [new ExchangeBoundDescriptor { Name = "shop", Type = ExchangeTypes.Direct, Queues = [queue] }],
    Confirmation = { Enabled = true }
};

await using var publisher = new PublisherBound(publisherDescriptor, formatter, channels.Build("shop-publisher"));
await publisher.SendAsync(new Message<Order> { Id = "order-1", Route = "created", Data = new Order("order-1", 49.90m) });

var subscriberDescriptor = new SubscriberBoundDescriptor
{
    PrefetchCount = 10,
    Queue = new QueueDescriptor { Name = "orders", Durable = true, AutoDelete = false }
};

await using var subscriber = new SubscriberBound<Order>(subscriberDescriptor, formatter, channels.Build("shop-subscriber"));
subscriber.Received.Add(async (_, e) => await Process(e.Message.Data));   // acknowledged unless e.Acknowledged = false
await subscriber.Start();                            // consumes only if there is a handler on Received

In an application, register ChannelFactory as IChannelFactory, the descriptors and the formatter in the container instead.

Good to know

  • RabbitMQ 4 refuses queues that are neither durable nor exclusive, and Durable is false by default: set Durable = true.
  • Subscribers need DispatchConsumersAsync = true. Without it no message arrives and no error is raised.
  • Delivery is at least once. A message is acknowledged after the handlers have run. The library recovers connections, channels and consumers by itself after a loss of connection (tested), and a message that was being processed is delivered again.
  • Retry. The subscribers have a RetryPolicy (off by default): a failed message is republished with a counter and delivered again after Delayed, up to MaxRetry, then OnMaxRetryFailed. The publishers' retry policy is on by default (5 attempts, 5 seconds doubling): turn it off or tune it if a refusal must come out quickly.
  • Confirmations. With Confirmation = { Enabled = true } the answers of the broker arrive as events of OnChannelEventFired, since sending does not wait for them. e.Publications lists the publications an answer is about (sequence number, exchange, route, message id), for auditing; set the Id of the message to match them. The broker may group answers, so one event can list many publications. The sequence number starts again from 1 after a connection is recovered.
  • message.Tag is no longer set. DeliveryConfirmation.WaitFor and Timeout are obsolete: they do not exist in 4.x.

Moving to 4.x

Change the version of the package. A consumer sees: no DispatchConsumersAsync (remove it); the confirmations are decided when the channel is created (channels.Build(name, descriptor.Confirmation)) and SendAsync then waits for the broker and throws PublishException on a refusal; IModel becomes IChannel if your code names it; net8.0 is the minimum. The repository README.md has the whole table.

See the documentation.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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 ServiceBus.Core.Rabbit:

Package Downloads
ServiceBus.AspNetCore.Rabbit

This is a custom library which implements subcribers injected as IHttpApplication, enabling to forward messages into WebAPI endpoint controllers.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.9.0 216 11/20/2026
3.8.2 878 4/4/2026
3.8.1 597 1/22/2026
3.7.1 2,575 4/12/2025
3.6.1 467 4/3/2025
3.5.2 557 3/7/2025
3.5.1 422 3/6/2025
3.4.2 415 2/25/2025
3.4.1 1,069 10/16/2024
3.3.1 365 10/2/2024
3.2.1 363 9/11/2024
3.1.1 1,305 3/21/2024
2.1.2 1,694 9/12/2023
2.1.1 310 9/11/2023
1.1.26 1,634 7/13/2023
1.1.25 451 4/22/2023
1.0.24 1,240 1/13/2023
1.0.23 683 1/6/2023
1.0.22 490 1/4/2023
1.0.21 2,105 12/24/2022
Loading failed