Depth understanding support ActiveMQ class 2 message reception queue and topic model

ActiveMQ is a very popular service middleware message queues, based on JMS (Java Message Service) specification, and it is a pure Java program, operating environment requires only a Java virtual machine.


JMS specification defines a message sending and receiving class 2 model: point to point queue, publish and subscribe topic, it is able to distinguish whether the duplication of spending and saving.


1, point queue: the consumer can not be repeated until the message is stored before consumption.

Producers send messages to the queue, a consumer withdraws and consume messages.

After the message is consumed, Queue is no longer saved, all consumers can take only one message.

Support for multiple consumer queue exist, but only one message a consumer can consume.

The current absence of consumers, the message remains stored until it is consumer spending.

image.png

2, publish and subscribe topic: repeat consumption, distributed to all subscribers.

Producer posted a message to the topic, the more subscribers receive and consume messages.

And different queue, messages posted to the topic will be consumed all subscribers.

When the producers announced that regardless of whether subscribers, do not save the message.

image.png

JMS specification defines a class 2 message transmission queue and topic model comparison:


Queue

Topic

model

Point Point-to-Point

Publish-Subscribe publish / subscribe

Whether the state

q ueue news before consumption has been saved on the server mq of files or configuration DB

topic data is not saved by default, it is stateless.

Integrity assurance

queue to ensure that each message received by consumers

topic does not guarantee that each message producer released are subscribers received

Whether the message will be lost

Message sent by the producer to the queue, the consumer receives the message. If no consumer would have been saved, not lost.

When the producers announced to the topic, the current subscribers are able to receive the messages. If you are not currently a subscriber, the message is lost.

Receiving news release strategy

One receives the policy news release, a news producer sent only received a consumer. After mq server receives the reply, the message will be deleted.

Many receive policy news release, the same topic multiple subscribers can receive news producer released.


Guess you like

Origin blog.51cto.com/13851865/2471218