The two message transmission modes in the JMS specification are topic and queue, which are compared in the following table ():
|
Topic |
Queue |
Profile |
Publish Subscribe Messaging Publish subscription message |
Point-to-Point point-to-point |
There is no status |
Topic data is not landed by default and is stateless. |
Queue data is saved as a file by default on the MQ server, such as Active MQ, which is typically stored under $amq_home\data\kr-store\data. Can also be configured as DB storage. |
Integrity Assurance |
There is no guarantee that every piece of data published by publisher will be accepted by subscriber. |
The queue guarantees that each piece of data can be received by receiver. |
Whether the message will be lost |
In general, when Publisher publishes a message to a topic, only the sub that is listening to the topic address can receive the message, and if no sub is listening, the topic is lost. |
Sender sends a message to the target Queue,receiver can receive the message on this queue asynchronously. Messages on the queue are not lost if they are not currently being picked up by receiver. |
Message Publishing Receive Policy |
A one-to-many message publishing receive policy that listens to multiple sub-topic addresses to receive messages from Publisher. Sub receives notification MQ server |
One message to the receiving policy, a sender sends a message, only one receiver receives. After receiver is received, the MQ server is notified that the MQ server has deleted or otherwise acted on the messages in the queue. |
mq-transmission mode topic vs. queue