Message-driven Bean (ii) --- comparison between point-to-point and publish subscription models

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.