Sobes.tech
Junior — Middle

How deep are you familiar with RabbitMQ and its capabilities?

sobes.tech AI

Answer from AI

I am familiar with the main concepts of RabbitMQ and its capabilities, including:

  • Basics of working with message queues, exchanges, and bindings.
  • Types of exchanges: direct, fanout, topic, headers, and their applications.
  • Main interaction protocols, such as AMQP.
  • Setting up message acknowledgments and handling failures.
  • Working with durable queues and TTL.

Example of a simple sender and receiver in Node.js using amqplib:

const amqp = require('amqplib');

async function send() {
  const conn = await amqp.connect('amqp://localhost');
  const channel = await conn.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(() => { conn.close(); process.exit(0); }, 500);
}

send();

This allows me to use RabbitMQ for organizing asynchronous interaction between services.