Sobes.tech
Junior — Middle

What tool or library have you used for RabbitMQ integration in your projects?

sobes.tech AI

Answer from AI

For integration with RabbitMQ in C# projects, the RabbitMQ.Client library is often used — the official client from the RabbitMQ developers. It provides a convenient API for connecting, sending, and receiving messages.

Example of a simple message sender:

using RabbitMQ.Client;
using System.Text;

var factory = new ConnectionFactory() { HostName = "localhost" };
using var connection = factory.CreateConnection();
using var channel = connection.CreateModel();

channel.QueueDeclare(queue: "hello", durable: false, exclusive: false, autoDelete: false, arguments: null);

string message = "Hello RabbitMQ!";
var body = Encoding.UTF8.GetBytes(message);

channel.BasicPublish(exchange: "", routingKey: "hello", basicProperties: null, body: body);
Console.WriteLine(" [x] Sent {0}", message);

Besides RabbitMQ.Client, wrapper libraries and frameworks like MassTransit or EasyNetQ are sometimes used to simplify work, providing a higher-level API and integration with DI containers.