Sobes.tech
Senior

Tell me about message brokers, which ones have you worked with?

sobes.tech AI

Answer from AI

Message brokers are systems that facilitate the transfer of messages between applications or services, allowing them to exchange data asynchronously and reliably. They support various exchange models such as queues (point-to-point) and publish-subscribe (pub/sub).

Among the brokers I have worked with:

  • RabbitMQ: supports AMQP, suitable for complex message routing, guarantees delivery.
  • Apache Kafka: focused on high throughput and stream storage, often used for event processing and logging.
  • ActiveMQ: a classic broker with JMS support, suitable for integration into Java applications.

Example of using RabbitMQ in Java with the amqp-client library:

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 World!";
    channel.basicPublish("", "task_queue", MessageProperties.PERSISTENT_TEXT_PLAIN, message.getBytes());
    System.out.println(" [x] Sent '" + message + "'");
}

Using brokers allows building scalable and fault-tolerant systems.

Tell me about message brokers, which ones have you… - sobes.tech