JMS Learning (v) persistence and non-persistence of messages in--activemq and differences and linkages between persistent and non-persistent subscribers

Source: Internet
Author: User
Tags to domain

One, the persistence and non-persistence of messages

①deliverymode

This is the transfer mode. The ACTIVEMQ supports two transport modes: persistent and non-durable (persistent and non-persistent delivery), which are used by default for durable transmissions.

the transfer mode can be set through the Setdeliverymode method of the MessageProducer class:

MessageProducer producer = ...; Producer.setdeliverymode (deliverymode.persistent);

The biggest difference between durable and non-durable transmissions is that when you use durable transmissions, the messages that are transmitted are saved to disk (messages is persisted to disk/database), which is the "store and forward" mode. The message is stored on disk before the message is "forwarded" to the Subscriber.

When a non-durable transport is used, the messages sent are not stored on disk.

With a durable transfer, the message is still there when the borker is resumed. With non-durable transmission, the message is lost when the Borker is restarted. For example, when a producer posts a message to the broker, the broker stores the message to disk, and the broker goes down before the broker sends the message to Subscriber, and if the broker restarts after a durable transfer, The message is read from disk and passed to subscriber, and if non-persistent transmission is used, the message is lost.

For official documentation of transfer modes, refer to

The difference between message durability and message persistence: I saw it in "ActiveMQ in action" and understood the following:

②message Persistence

Independent

This shows: 1) Message persistence is not related to domain. 2) Messagepersistence is related to the transport mode, and if a message uses a durable transmission, the message has a persistence nature, otherwise it is not.

③durability of messages (Message durability)

topic, they can do so using a durable or a non-durable subscription.

The above shows two points: 1) Durability of messages only for the publishing subscription model (Domain). 2) Persistent and non-persistent subscriptions are for topic, not for queue .

That is, if a message is subscribed to by a persistent subscriber, then the message has: durability, or nondurability

Two, persistent subscribers and non-persistent subscribers

①durable subscribers and Nondurable subscribers

First, the domain that persistent and non-persistent subscribers target is pub/sub, not peer

When the broker sends a message to the subscriber, if the Subscriber is in the inactive state : The durable subscriber can receive the message, but not the persistent Subscriber.

Similar to the QQ message, someone sent you offline messages, if the non-persistent subscribers will receive no offline messages.

The effect is that when the persistent subscriber is in the inactive state, the broker needs to save the message for the durable subscriber, and overflows if the persistent subscriber subscribes too many messages. (When the message is delivered successfully, the broker can delete the message)

A specific official example is as follows:

For example imagine a durable subscriber S starts up subscribing to topic T at time D1. Some Publisher sends messages M1, M2, M3 to the topic and S'll receive each of the these messages. Then S are stopped and the publisher continues to send M4, M5. When S restarts at D2, the publisher sends M6 and M7. Now S'll receive M4, M5 followed by M6 and M7 and all for future messages. i.e. S would receive all messages from M1. M7. This is the difference between durable and non-durable consuming. If S were a non-durable consumer then it would only has received M1, M2, M3 and M6, M7-not M4 and M5.  i.e because the subscription is durable, S would receive every message sent to T whether the Subscriber are running or not. For non-durable topics, only messages delivered to the topic T when S was running is delivered.

②durable Queues (Topics) and nondurable Queues (Topics)

Differences: Reference Links III, references http://blog.christianposta.com/guaranteed-messaging-for-topics-the-jms-spec-and-activemq/

Understanding the transport mode and message persistence for messages in the JMS specification

Understanding persistent and non-persistent subscriptions in the JMS specification

JMS Learning (v) persistence and non-persistence of messages in--activemq and differences and linkages between persistent and non-persistent subscribers

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.