Junior — Middle
Describe your experience with message brokers or data queues in projects.
sobes.tech AI
Answer from AI
In my projects, I used message brokers such as RabbitMQ and Apache Kafka to organize asynchronous data exchange between microservices. For example, with RabbitMQ, I configured queues and exchanges to handle background tasks, which helped unload the main application flow and increase scalability.
Example of using RabbitMQ with Node.js:
const amqp = require('amqplib');
async function sendMessage() {
const connection = await amqp.connect('amqp://localhost');
const channel = await connection.createChannel();
const queue = 'task_queue';
const msg = 'Hello World';
await channel.assertQueue(queue, { durable: true });
channel.sendToQueue(queue, Buffer.from(msg), { persistent: true });
console.log(" [x] Sent '%s'", msg);
setTimeout(() => {
connection.close();
process.exit(0);
}, 500);
}
sendMessage();
This approach ensures reliable message delivery, queue processing order, and fault tolerance.