RabbitMQ.NET
1.0.4
.NET 5.0
This package targets .NET 5.0. The package is compatible with this framework or higher.
.NET Core 3.1
This package targets .NET Core 3.1. The package is compatible with this framework or higher.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package RabbitMQ.NET --version 1.0.4
NuGet\Install-Package RabbitMQ.NET -Version 1.0.4
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="RabbitMQ.NET" Version="1.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RabbitMQ.NET --version 1.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: RabbitMQ.NET, 1.0.4"
#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.
// Install RabbitMQ.NET as a Cake Addin #addin nuget:?package=RabbitMQ.NET&version=1.0.4 // Install RabbitMQ.NET as a Cake Tool #tool nuget:?package=RabbitMQ.NET&version=1.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
RabbitMQ Client library for .NET Core
Library Version: v1.0.3
Installation
Install-Package RabbitMQ.NET
Usage
RabbitMQ.NET is a simple library to Publish and Subscribe easily in .NET Core applications.
Setup DI
var serviceProvider = new ServiceCollection()
.AddLogging(loggingBuilder =>
{
loggingBuilder.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
})
.AddRabbitMQCore(options =>
{
options.HostName = "localhost";
})
.BuildServiceProvider();
Get QueueService
var rmq = serviceProvider.GetRequiredService<IQueueService>();
Publisher Examples
Publish on Exchange
var pub1 = rmq.CreatePublisher(options =>
{
options.ExchangeOrQueue = RabbitMqCore.Enums.ExchangeOrQueue.Exchange;
options.ExchangeName = "exchange.1";
options.ExchangeType = RabbitMqCore.Enums.ExchangeType.direct;
});
var obj = new SimpleObject() { ID = 1, Name = "One" };
var message = new RabbitMessageOutbound()
{
Message = JsonConvert.SerializeObject(obj)
};
pub1.SendMessage(message);
Publish on Exchange with Routing Key
var pub2 = rmq.CreatePublisher(options =>
{
options.ExchangeOrQueue = RabbitMqCore.Enums.ExchangeOrQueue.Exchange;
options.ExchangeName = "exchange.1";
options.ExchangeType = RabbitMqCore.Enums.ExchangeType.direct;
options.RoutingKeys.Add("routing.key");
});
var obj2 = new SimpleObject() { ID = 2, Name = "Two" };
var message2 = new RabbitMessageOutbound()
{
Message = JsonConvert.SerializeObject(obj2)
};
pub2.SendMessage(message2);
Publish on Queue
var pub3 = rmq.CreatePublisher(options =>
{
options.ExchangeOrQueue = RabbitMqCore.Enums.ExchangeOrQueue.Queue;
options.QueueName = "queue.3";
});
pub3.SendMessage(message);
Subscriber Examples
Subscribe with Exchange, Queue and with Routing Key
var sub1 = rmq.CreateSubscriber(options =>
{
options.ExchangeOrQueue = RabbitMqCore.Enums.ExchangeOrQueue.Exchange;
options.ExchangeName = "exchange.1";
options.QueueName = "queue.1";
options.RoutingKeys.Add("routing.key.1");
});
sub1.Subscribe(opt => { Console.WriteLine("sub 1 called: {0}", opt.ToString()); });
Subscribe with Queue
var sub3 = rmq.CreateSubscriber(options =>
{
options.ExchangeOrQueue = RabbitMqCore.Enums.ExchangeOrQueue.Queue;
options.QueueName = "queue.3";
});
sub3.Subscribe(opt => { Console.WriteLine("sub 3 message:{0}", opt.Message); });
Subscribe with Exchange. Temporary queue will be created automatically
var sub4 = rmq.CreateSubscriber(options =>
{
options.ExchangeOrQueue = RabbitMqCore.Enums.ExchangeOrQueue.Exchange;
options.ExchangeName = "exchange.1";
});
sub4.Subscribe(opt => { Console.WriteLine("sub 4 called: {0}", opt.ToString()); });
Subscribe to Exchange with Routing key
var sub5 = rmq.CreateSubscriber(options =>
{
options.ExchangeOrQueue = RabbitMqCore.Enums.ExchangeOrQueue.Exchange;
options.ExchangeName = "exchange.1";
options.RoutingKeys.Add("routing.key.2");
});
sub5.Subscribe(opt => { Console.WriteLine("sub 5 called: {0}", opt.ToString()); });
Subscribe to Exchange and Queue with TTL
var sub6 = rmq.CreateSubscriber(options =>
{
options.ExchangeOrQueue = RabbitMqCore.Enums.ExchangeOrQueue.Exchange;
options.ExchangeName = "exchange.1";
options.QueueName = "queue.4";
options.Arguments.Add(ArgumentStrings.XMessageTTL, 5000);
});
sub6.Subscribe(opt => { Console.WriteLine("sub 6 called: {0}", opt.ToString()); });
License
This library licensed under the MIT license.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
.NET Core | netcoreapp3.1 is compatible. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETCoreApp 3.1
- Microsoft.Extensions.DependencyInjection (>= 3.1.20)
- Microsoft.Extensions.Logging (>= 3.1.20)
- RabbitMQ.Client (>= 6.2.2)
-
net5.0
- Microsoft.Extensions.DependencyInjection (>= 5.0.0)
- Microsoft.Extensions.Logging (>= 5.0.0)
- RabbitMQ.Client (>= 6.2.2)
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 |
---|---|---|
3.2.0 | 5,793 | 9/21/2022 |
3.1.1 | 468 | 9/15/2022 |
3.1.0 | 433 | 9/15/2022 |
3.0.1 | 449 | 9/14/2022 |
3.0.0 | 459 | 9/14/2022 |
2.1.0 | 452 | 9/8/2022 |
2.0.0 | 423 | 9/7/2022 |
1.1.0 | 439 | 9/7/2022 |
1.0.5 | 432 | 9/4/2022 |
1.0.4 | 487 | 5/11/2022 |
1.0.3 | 347 | 1/2/2022 |
1.0.2 | 296 | 1/2/2022 |
1.0.1 | 294 | 12/30/2021 |
1.0.0 | 553 | 10/25/2021 |
reconnect fixes