Message brokers let microservices communicate asynchronously by relaying messages between them, so services can interact without being directly connected or available at the same time.
When an order is placed, the Order service publishes an event to a message broker instead of calling the Notification and Analytics services directly; both consume the event independently, and if the Analytics service is temporarily down, its messages simply wait in the broker until it comes back online.
// Order service publishes one event and doesn't know who consumes it
kafkaTemplate.send("order-events", order.id(), new OrderPlaced(order.id(), order.email()));
// Notification service
@KafkaListener(topics = "order-events", groupId = "notification-service")
public void sendEmail(OrderPlaced event) {
emailService.sendConfirmation(event.email(), event.orderId());
}
// Analytics service: a separate group, so it gets its own copy of every event
@KafkaListener(topics = "order-events", groupId = "analytics-service")
public void record(OrderPlaced event) {
salesStats.increment(event.orderId());
}
// If the notification service is down, events wait in Kafka until it is back.A concise interview answer is
Message brokers act as an intermediary that decouples services in time: a producer publishes a message without needing to know who consumes it or whether they're currently available. That improves scalability, since I can add consumers independently, and resilience, since a broker like Kafka or RabbitMQ queues messages reliably until a consumer is ready to process them.
Last updated: 1 November 2026
Previous question: What is the difference between synchronous and asynchronous communication in microservices?
Next question: What are some of the risks involved with inter-service communication?