1. Peer model
The following concepts are found in the peer-to model: Message Queuing (queue), Sender (sender), receiver (receiver). Each message is sent to a specific queue, and the recipient obtains the message from the queue. The queue retains the message until they are consumed or timed out .
? only one consumer per message (Consumer) (that is, once consumed, the message is no longer in the message queue)
? there is no dependency on time between the sender and the receiver , that is, when the sender sends a message, it does not affect the message being sent to the queue, regardless of whether the recipient is running.
? the recipient needs to answer the queue successfully after receiving the message successfully
If every message you want to send should be handled successfully , then you need a peer model.
Application: Want the receiver to do and only once processing
Synchronous communication between components
2 Pub/sub Model
In the PUB/SUB model, there are the following concepts: Subject (Topic), publisher (publisher), Subscriber (subscriber). The client sends the message to the topic. Multiple publishers send messages to topic, which the system passes to multiple subscribers.
? Each message can have multiple consumers
? There is a time dependency between the Publisher and the Subscriber . Subscribers to a topic (TOPIC) must create a subscription before they can consume the publisher's message and, in order to consume the message, the Subscriber must remain in a running state.
Of course, to mitigate this strict time dependency, JMS allows subscribers to create a durable subscription. This way, even if the Subscriber is not activated (running), it can receive the message from the publisher.
If you want to send a message that can be processed without being processed, or handled by a consumer, or can be processed by multiple consumers , then you can use the Pub/sub model (that is, the publisher doesn't care about how many listeners).
About the dependence of time
The results of the implementation of two models:
There can only be one consumer for each message of the peer-to- peer model If we define two message receiver's beans then only one end will receive the message. When you get rid of the message receiving bean deployed in JBoss and then send the message at this time the message is in the queue and once you redeploy he will immediately receive the message just sent so it has no time dependency,
pub/sub models can have multiple consumers in this model if we define multiple beans that receive messages when we send a message to the client, two beans will receive the message, so he has multiple consumers but If you remove the message receiving bean from JBoss deployment, send a message. Then after redeployment, the message is not received , so he has a time dependency.
Two modes of JMS p2p,pub/sub message sending