DotNetBaseQueue.RabbitMQ.Handler
9.0.0
See the version list below for details.
dotnet add package DotNetBaseQueue.RabbitMQ.Handler --version 9.0.0
NuGet\Install-Package DotNetBaseQueue.RabbitMQ.Handler -Version 9.0.0
<PackageReference Include="DotNetBaseQueue.RabbitMQ.Handler" Version="9.0.0" />
<PackageVersion Include="DotNetBaseQueue.RabbitMQ.Handler" Version="9.0.0" />
<PackageReference Include="DotNetBaseQueue.RabbitMQ.Handler" />
paket add DotNetBaseQueue.RabbitMQ.Handler --version 9.0.0
#r "nuget: DotNetBaseQueue.RabbitMQ.Handler, 9.0.0"
#:package DotNetBaseQueue.RabbitMQ.Handler@9.0.0
#addin nuget:?package=DotNetBaseQueue.RabbitMQ.Handler&version=9.0.0
#tool nuget:?package=DotNetBaseQueue.RabbitMQ.Handler&version=9.0.0
DotNetBaseQueue
This library aims to facilitate the use of asynchronous processes in .NET projects, with an initial focus entirely on RabbitMQ.
Installation
Message Publishing
dotnet add package DotNetBaseQueue.RabbitMQ.Publish
Message Consumption by Handler
dotnet add package DotNetBaseQueue.RabbitMQ.Handler
Sending Messages
To send messages, add the following to your services:
builder.Services.AddQueuePublishSingleton(CONFIG_APPSETTINGS);
To send a message, use dependency injection to get the IQueuePublish interface and utilize the available method.
Example:
public class TestController : BaseController
{
private readonly IQueuePublish _queuePublish;
public TestController(IQueuePublish queuePublish)
{
_queuePublish = queuePublish;
}
[HttpPost]
public IActionResult PostEntity(object obj)
{
_queuePublish.Publish(obj, CONFIG_PublishSectionQueue);
return Ok();
}
[HttpPost]
public IActionResult PostEntities(List<object> objects)
{
_queuePublish.PublishList(objects, CONFIG_PublishSectionQueue);
return Ok();
}
}
Adding a Consumer
The message object must implement the IRabbitEvent interface or IRabbitEventRetry (for using retry).
The class for message processing must implement the IRabbitEventHandler interface.
Add the consumer to your .NET services using the AddWorkerConfiguration and AddHandler Methods.
Example:
Startup:
services
.AddWorkerConfiguration(configuration, CONFIG_APPSETTINGS)
.AddHandler<SendMessageHandler, Message>(CONFIG);
public class Message : IQueueEvent
{
public string SenderId { get; set; }
}
public class SendMessageHandler : IQueueEventHandler<Message>
{
public async Task HandleAsync(Message command)
{
// Handle the message
}
}
Configuring appsettings.json
You can configure the appsettings.json file as follows:
Base:
"QueueConfiguration": {
"HostName": "",
"Port": 5672,
"UserName": "",
"Password": "",
"VirtualHost": "/"
},
Only handler config:
"QueueConfiguration": {
"ExchangeName": "",
"ExchangeType": "direct",
"RoutingKey": "",
"QueueName": "",
"NumberOfWorkroles": 1,
"CreateDeadLetterQueue": true,
"CreateRetryQueue": true,
"SecondsToRetry": 15,
"NumberTryRetry": 3
},
All:
"QueueConfiguration": {
"HostName": "",
"Port": 5672,
"VirtualHost": "/",
"UserName": "",
"Password": "",
"ExchangeName": "",
"ExchangeType": "direct",
"RoutingKey": "",
"QueueName": "",
"NumberOfWorkroles": 1,
"CreateDeadLetterQueue": true,
"CreateRetryQueue": true,
"SecondsToRetry": 15,
"NumberTryRetry": 3
},
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. 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 is compatible. 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 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 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. |
-
net5.0
- DotNetBaseQueue.RabbitMQ.Core (>= 9.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 9.0.1)
- Microsoft.Extensions.Hosting.Abstractions (>= 9.0.1)
- Microsoft.Extensions.Logging.Configuration (>= 9.0.1)
-
net6.0
- DotNetBaseQueue.RabbitMQ.Core (>= 9.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 9.0.1)
- Microsoft.Extensions.Hosting.Abstractions (>= 9.0.1)
- Microsoft.Extensions.Logging.Configuration (>= 9.0.1)
-
net7.0
- DotNetBaseQueue.RabbitMQ.Core (>= 9.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 9.0.1)
- Microsoft.Extensions.Hosting.Abstractions (>= 9.0.1)
- Microsoft.Extensions.Logging.Configuration (>= 9.0.1)
-
net8.0
- DotNetBaseQueue.RabbitMQ.Core (>= 9.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 9.0.1)
- Microsoft.Extensions.Hosting.Abstractions (>= 9.0.1)
- Microsoft.Extensions.Logging.Configuration (>= 9.0.1)
-
net9.0
- DotNetBaseQueue.RabbitMQ.Core (>= 9.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 9.0.1)
- Microsoft.Extensions.Hosting.Abstractions (>= 9.0.1)
- Microsoft.Extensions.Logging.Configuration (>= 9.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.