Sobes.tech
Junior — Middle

Do you have experience using RabbitMQ in your projects?

sobes.tech AI

Answer from AI

Yes, I have experience using RabbitMQ in C# projects. RabbitMQ is a message broker that allows applications to exchange messages asynchronously and reliably.

In C#, the RabbitMQ.Client library is often used to work with RabbitMQ. The main scenarios include:

  • Sending messages (publisher)
  • Receiving messages (subscriber)
  • Setting up queues and exchanges

Example of a simple message sender in C#:

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);

RabbitMQ helps build scalable and fault-tolerant systems through asynchronous message exchange.