Junior — Middle
Have you used RabbitMQ in any of your projects?
sobes.tech AI
Answer from AI
Yes, I have used RabbitMQ in several Node.js projects to facilitate message exchange between microservices and asynchronous task processing.
RabbitMQ is a message broker that supports various exchange models (queues, topics, direct exchanges).
Example of usage with the amqplib library:
const amqp = require('amqplib');
async function sendMessage() {
const connection = await amqp.connect('amqp://localhost');
const channel = await connection.createChannel();
const queue = 'task_queue';
await channel.assertQueue(queue, { durable: true });
const msg = 'Hello RabbitMQ';
channel.sendToQueue(queue, Buffer.from(msg), { persistent: true });
console.log(" [x] Sent '%s'", msg);
setTimeout(() => {
channel.close();
connection.close();
}, 500);
}
sendMessage();
RabbitMQ helps unload main services, ensuring reliable message delivery and system scalability.