Junior — Middle
Have you had practical experience using message exchange systems through brokers?
sobes.tech AI
Answer from AI
Yes, I have practical experience working with messaging systems through brokers such as RabbitMQ and Apache Kafka. In C# projects, I used these brokers to organize asynchronous interactions between microservices. This helps to offload main services, increase scalability, and ensure reliable message delivery.
Example of using RabbitMQ with C# (using the RabbitMQ.Client library):
var factory = new ConnectionFactory() { HostName = "localhost" };
using(var connection = factory.CreateConnection())
using(var channel = connection.CreateModel())
{
channel.QueueDeclare(queue: "task_queue",
durable: true,
exclusive: false,
autoDelete: false,
arguments: null);
string message = "Hello World!";
var body = Encoding.UTF8.GetBytes(message);
var properties = channel.CreateBasicProperties();
properties.Persistent = true;
channel.BasicPublish(exchange: "",
routingKey: "task_queue",
basicProperties: properties,
body: body);
Console.WriteLine(" [x] Sent {0}", message);
}