JMS is a Java Message Service. JMS clients can transmit messages asynchronously through the JMS service. JMS supports two message models: point-to-point (P2P) and publish/subscribe (pub/Sub), that is, point-to-point and publish subscription models.
P2P
The P2P model has the following concepts: queue, sender, and receiver ). Each message is sent to a specific queue, and the receiver obtains the message from the queue. The queue retains messages until they are consumed or time-out.
L each message has only one consumer (that is, once consumed, the message is no longer in the Message Queue)
L there is no time dependency between the sender and the receiver. That is to say, after the sender sends a message, no matter whether the receiver is running or not, it will not affect the message being sent to the queue.
L the receiver must respond to the queue successfully after receiving the message.
If you want to send every message to be processed successfully, you need a P2P model.
Pub/sub
The pub/sub model has the following concepts: topic, publisher, and subscriber ). The client sends the message to the topic. Multiple publishers send messages to topics. The system sends these messages to multiple subscribers.
L each message can have multiple consumers
L there is a time-dependent relationship between the publisher and the subscriber. For a subscriber of a topic, a subscriber must create a subscription to consume the message of the publisher. to consume the message, the subscriber must maintain the running status.
Of course, to ease this strict time correlation, JMS allows subscribers to create a persistent subscription. In this way, even if the subscriber is not activated (running), it can receive messages from the publisher.
If the message you want to send can be processed by one consumer or multiple consumers, you can use the pub/Sub Model.