SHAKA.MessageBus.RabbitMQ 1.0.8

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

MessageBus.RabbitMQ Project

The second project is MessageBus.RabbitMQ, which is a specific implementation of the EventBus using RabbitMQ as the message broker.

The main class here is RabbitMQEventBus, which implements both IEventBus and IHostedService. This means it serves as both an event bus and a background job. Its primary responsibility is to establish a connection to RabbitMQ as soon as it starts. It then declares exchanges, queues, and binds them for each SubscriptionInfo. Some projects may not require any subscriptions.

The OnMessageReceived method is responsible for registering event handlers for specific events retrieved from SubscriptionInfo. This method then calls ProcessEvent, which resolves the event handler from the DI container using the event’s name and registers it with the broker. Withing it it calls the ProcessEvent() method which is responsible for resolving all the eventHandlers for the specific events and invoking them, right before the invokation it checks for an existance of the failedMessageChain for the given entities EntitiyId, if there is a chain, handler won't be invoked and the event will be added in the failed message chain. If the invoked handler throws an exception, we use AddInFailedMessageChain() method to create a failed message chain and add this event as a first failed message.

Another critical method is PublishAsync, which takes an IntegrationEvent. This method retrieves the name and full name of the event and looks for an exchange with the same name. It then publishes the event there using the event name as the routing key.

To ensure resiliency, events are published via ResiliencePipeline, which allows us to configure different resiliency strategies. Currently, we use a Retry Strategy that handles BrokerUnreachableException and SocketException, with the retry count configurable via EventBusOptions in appsettings.json.

To register RabbitMQEventBus in the DI container as both IEventBus and IHostedService, we use the RabbitMqDependencyInjectionExtensions class. The extension methods also require the consumer to configure the ConnectionFactory for the broker.

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 was computed.  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 was computed.  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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.8 112 9/4/2025
1.0.7 110 9/4/2025
1.0.6 478 3/26/2025
1.0.5 169 3/20/2025
1.0.4 154 3/20/2025
1.0.3 156 3/20/2025
1.0.2 159 3/17/2025
1.0.1 156 3/17/2025
1.0.0 102 3/14/2025