RabbitMQ.Connect.Helper
1.0.1
See the version list below for details.
dotnet add package RabbitMQ.Connect.Helper --version 1.0.1
NuGet\Install-Package RabbitMQ.Connect.Helper -Version 1.0.1
<PackageReference Include="RabbitMQ.Connect.Helper" Version="1.0.1" />
<PackageVersion Include="RabbitMQ.Connect.Helper" Version="1.0.1" />
<PackageReference Include="RabbitMQ.Connect.Helper" />
paket add RabbitMQ.Connect.Helper --version 1.0.1
#r "nuget: RabbitMQ.Connect.Helper, 1.0.1"
#:package RabbitMQ.Connect.Helper@1.0.1
#addin nuget:?package=RabbitMQ.Connect.Helper&version=1.0.1
#tool nuget:?package=RabbitMQ.Connect.Helper&version=1.0.1
RabbitMQ Connection Helper
A .NET NuGet package to simplify working with RabbitMQ for producing and consuming messages. This package provides an easy-to-use interface for managing connections, exchanges, queues, and publishing/consuming messages in a RabbitMQ environment.
Features
- Asynchronous support for RabbitMQ connections.
- Simplified message publishing and consumption.
- Built-in support for durable queues and exchanges.
- Helper methods for creating producers and consumers.
Installation
Install the package via NuGet Package Manager:
Install-Package ConnectRabbitMq
Or via the .NET CLI:
dotnet add package ConnectRabbitMq
Usage
1. Add Appsetings.json
"RabbitMqConfig": {
"HostName": "localhost",
"Port": 5672,
"UserName": "guest",
"Password": "guest"
}
2. Setup RabbitMQ Connection
var factory = new ConnectionFactory
{
HostName = "localhost",
Port = 5672,
UserName = "guest",
Password = "guest",
};
// Create a connection and a channel
using var connection = await factory.CreateConnectionAsync();
using var channel = await connection.CreateChannelAsync();
3. Publish Messages
var exchangeName = "example-exchange";
var routingKey = "example-key";
var message = "Hello, RabbitMQ!";
await RabbitMQHelper.PublishMessageAsync(channel, exchangeName, routingKey, message);
4. Consume Messages
var queueName = "example-queue";
await RabbitMQHelper.ConsumeMessagesAsync(channel, queueName, async (message) =>
{
Console.WriteLine($"Received: {message}");
// Process the message
});
5. Helper Methods
PublishMessageAsync
Publishes a message to a specific exchange with a routing key.
await RabbitMQHelper.PublishMessageAsync(channel, exchangeName, routingKey, message);
ConsumeMessagesAsync
Starts consuming messages from a queue.
await RabbitMQHelper.ConsumeMessagesAsync(channel, queueName, messageHandler);
Configuration
- Exchange Type: Supports
direct
,topic
,fanout
, andheaders
. - Durability: Ensures exchanges and queues are durable for reliable messaging.
- Auto Acknowledge: Messages are acknowledged automatically or manually.
Contributing
Contributions are welcome! If you find a bug or want to add a feature, feel free to open an issue or submit a pull request.
License
This package is licensed under the MIT License. See the LICENSE file for details.
Contact
For any issues or questions, feel free to reach out to the maintainer.
Product | Versions 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. |
-
net8.0
- Microsoft.Extensions.Options (>= 8.0.1)
- RabbitMQ.Client (>= 7.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.