Message Queue
Message queues provide an
asynchronous communications protocol
, meaning that the sender and receiver of the message do not need to interact with the message queue at the same time.
Most messaging systems support both the
publisher/subscriber
and message queue models in their API
Features of Message Queue
Messages are queued asynchronously
between applications and systems.
- Multiple
providers
canpost messages
to a queue - There can be multiple message
consumers
attached to asingle queue
- The queuing infrastructure ensures messages are delivered
exactly once
- Messages can be
successfully submitted
to a queue even if the message consumer(s) for that queue are not running or areunreachable
Benefits
Scalability
Reliability
Abstraction
since producers and consumers aren’t directly interconnected
Implementation
There are a number of open source choices of messaging middleware systems, including Apache
ActiveMQ
, ApacheKafka
, ApacheRocketMQ
,RabbitMQ
, etc.
JMS VS AMQP
JMS
The
Java Message Service
(JMS) API is aJava
Message Oriented Middleware (MOM
) API for sending messages betweentwo or more clients
. JMS is a part of theJava Platform
. It is amessaging standard
that allows application components based on the Java Enterprise Edition (Java EE
) to create, send, receive, and read messages. It allows the communication between different components of a distributed application to beloosely coupled
,reliable
, andasynchronous
.AMQP
The
Advanced Message Queuing Protocol
(AMQP) is anopen standard
wire-level protocol
for message-oriented middleware. The defining features of AMQP are
message orientation,
queuing,
routing(including
point-to-pointand
publish-and-subscribe`), reliability and security.
JMS is
API
and AMQP is aprotocol
. JMS is only a API spec. It doesn’t use any protocol. AJMS provider
(like ActiveMQ) could be using any underlying protocol to realize the JMS API.
ActiveMQ vs RabbitMQ vs Kafka
- Throughput
Kafka > RabbitMQ > ActiveMQ
- Latency
RabbitMQ(Erlang) < Kafka(Scala&Java) < ActiveMQ(Java)
- Infrastructure
RabbitMQ(AMQP, Distributed Platform)
Kafka(Distributed streaming platform)
ActiveMQ(JMS)