Junior — Middle
What was your experience working with the RabbitMQ messaging system?
sobes.tech AI
Answer from AI
In working with RabbitMQ, I used it as a message broker to organize asynchronous interaction between services. The main tasks included:
- Setting up queues and exchanges for message routing.
- Sending messages (producer) and receiving them (consumer) with delivery confirmation.
- Ensuring reliability through acknowledgments (acks) and message reprocessing.
- Using different types of exchanges: direct, topic, fanout for various routing scenarios.
For example, in Java, using the amqp-client library, I created a connection, channel, declared a queue, and published a message:
ConnectionFactory factory = new ConnectionFactory();
factory.setHost("localhost");
try (Connection connection = factory.newConnection();
Channel channel = connection.createChannel()) {
channel.queueDeclare("task_queue", true, false, false, null);
String message = "Hello RabbitMQ";
channel.basicPublish("", "task_queue",
MessageProperties.PERSISTENT_TEXT_PLAIN, message.getBytes("UTF-8"));
}