In-depth understanding of JMS

Explain in simple terms JMS


1.JMS (JAVA Message Service, java message service) API is a standard or specification of a message service, allowing application components to create, send, receive and read messages based on the JavaEE platform.
It makes distributed communication less coupled, messaging services more reliable and asynchronous.
2. JMS is a Java message service, and JMS clients can perform asynchronous message transmission through the JMS service.
3. Message model (Point-to-Point (P2P), Publish/Subscribe (Pub/Sub), namely point-to-point and publish-subscribe model) Concepts involved in


Point-to-Point (P2P) 1. Message Queue (Queue) 2 . Sender (Sender) 3. Receiver (Receiver) 4. Each message is sent to a specific queue, the receiver gets the message from the queue. Queues hold messages until they are consumed or time out. Features of P2P 1. Each message has only one consumer (Consumer) (that is, once consumed, the message is no longer in the message queue) 2. There is no time dependency between the sender and the receiver, that is, when After the sender sends a message, it doesn't affect the message being sent to the queue, whether the receiver is running or not . 3. The receiver needs to reply to the queue after successfully receiving the message . 4. If you want to send every message Should be processed successfully, then you need P2P mode. Concepts involved in Publish/Subscribe (Pub/Sub) 1. Topic
























2. Publisher
3. Subscriber
4. The client sends the message to the topic. Multiple publishers send messages to topics, and the system delivers these messages to multiple subscribers.


Features of Pub/Sub
1. Each message can have multiple consumers
2. There is a time dependency between publishers and subscribers. For a subscriber of a topic (Topic), it must create a subscriber before it can consume the message of the publisher, and in order to consume the message, the subscriber must keep the running state.
3. To ease such strict time dependencies, JMS allows subscribers to create a durable subscription. This way, even if the subscriber is not activated (running), it can receive messages from the publisher.
4. If the message you want to send can be processed without any processing, or processed by one messager, or can be processed by multiple consumers, then you can use the Pub/Sub model.



Message
consumption In JMS, message generation and Messages are asynchronous. For consumption, JMS messagers can consume messages in two ways.
1. Synchronous
subscribers or receivers call the receive method to receive messages. The receive method will block until the message can be received (or until timeout)
. 2. Asynchronous
subscribers or receivers can register as a message listener. When the message arrives, the system automatically calls the listener's onMessage method.



Reference to the original text: http://blog.csdn.net/jiuqiyuliang/article/details/46701559

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326989913&siteId=291194637