Message Queue Applications and Comparison of Common MQs (ActiveMQ, RabbitMQ, RocketMQ, Kafka)

This article explains the role of message queues in distributed systems, illustrates four typical scenarios—asynchronous processing, application decoupling, traffic shaping, and message communication—and compares the features of popular middleware such as ActiveMQ, RabbitMQ, RocketMQ, and Kafka.

Selected Java Interview Questions
Selected Java Interview Questions
Selected Java Interview Questions
Message Queue Applications and Comparison of Common MQs (ActiveMQ, RabbitMQ, RocketMQ, Kafka)

In previous projects we used Kafka and RabbitMQ; this article summarizes the importance of message‑queue middleware in distributed systems.

Message queues provide asynchronous messaging, application decoupling, traffic‑shaping, and efficient communication.

Below are concrete examples of how message queues are used in practice.

Message Queue Application Scenarios

1. Asynchronous Processing

Example: user registration requires sending a welcome email and SMS.

Serial approach: write to DB → send email → send SMS, total time ~150 ms.

Parallel approach: write to DB → send email and SMS concurrently, total time ~100 ms, increasing throughput.

Conclusion: traditional serial/parallel designs have performance bottlenecks; introducing a message queue can solve them.

After introducing a queue, the registration flow writes the email/SMS tasks to the queue and returns to the client immediately, reducing response time to the DB write latency (~50 ms) and raising throughput to ~20 QPS.

2. Application Decoupling

Example: order system needs to notify inventory system.

Traditional coupling: order service calls inventory API directly; failure of inventory causes order failure.

Solution: use a queue so the order service persists the order and publishes a message, while the inventory service consumes it independently.

If the inventory service is down, orders still succeed because the order service no longer waits for inventory.

3. Traffic Shaping (Peak‑Smoothing)

In flash‑sale scenarios, massive concurrent requests can overwhelm the system.

By placing a queue in front of the service, requests are buffered; excess requests can be rejected or redirected, protecting downstream services.

4. Message Communication

Message queues also provide built‑in communication patterns such as point‑to‑point and publish‑subscribe, useful for chat rooms or other real‑time messaging.

Common Message Queues

ActiveMQ, RabbitMQ, RocketMQ, Kafka Comparison

Producer‑Consumer Model

: all four support.

Publish‑Subscribe Model

: all four support.

Request‑Reply Model

: supported by ActiveMQ, RabbitMQ; not supported by RocketMQ, Kafka.

API Completeness

: high for all.

Multi‑Language Support

: ActiveMQ, RabbitMQ, Kafka support many languages; RocketMQ only Java.

Single‑Node Throughput

: ActiveMQ/RabbitMQ/RocketMQ – tens of thousands TPS; Kafka – hundreds of thousands TPS.

Message Latency

: ActiveMQ – none; RabbitMQ – microseconds; RocketMQ/Kafka – milliseconds.

Availability

: ActiveMQ/RabbitMQ – high (master‑slave); RocketMQ/Kafka – very high (distributed).

Message Loss

: ActiveMQ/RabbitMQ – low; RocketMQ/Kafka – theoretically none.

Documentation Quality

: high for all.

Quick‑Start Guides

: available for all.

Community Activity

: high for ActiveMQ, RabbitMQ, Kafka; medium for RocketMQ.

Commercial Support

: none for ActiveMQ/RabbitMQ; Alibaba Cloud for RocketMQ/Kafka.

Individual MQ Overviews

ActiveMQ

: mature, implements JMS 1.1, integrates with Spring‑JMS, supports many protocols, but heavier codebase and less optimal for large queue counts.

RabbitMQ

: mature, supports AMQP transactions, higher reliability than Kafka, better performance than ActiveMQ.

RocketMQ

: Alibaba‑originated, Java‑only, high throughput and availability, optimized for reliable transmission and transactions, widely used in Alibaba’s large‑scale scenarios.

Kafka

: designed for log processing, high throughput, not an AMQP‑compatible MQ, excels in big‑data streaming use cases.

Author: 小怪聊职场 Source: www.jianshu.com/p/1582b37291f9
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

System ArchitectureKafkaMessage QueueRabbitMQasynchronous processing
Selected Java Interview Questions
Written by

Selected Java Interview Questions

A professional Java tech channel sharing common knowledge to help developers fill gaps. Follow us!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.