简体   繁体   中英

JMS persistence of message

In the JMS publish / subscribe mode, two consumers subscribe same topic. One consumer is running, but another one is down when producer send message out, it still save the message for the consumer which is not up running ?

Thanks

I believe you can if you use the combination of Persistent message delivery and Durable subscription to the topic.

From: http://docs.oracle.com/javaee/5/tutorial/doc/bncdx.html

Pub/sub messaging has the following characteristics.

Each message can have multiple consumers.

Publishers and subscribers have a timing dependency. A client that subscribes to a topic can consume only messages published after the client has created a subscription, and the subscriber must continue to be active in order for it to consume messages.

The JMS API relaxes this timing dependency to some extent by allowing subscribers to create durable subscriptions, which receive messages sent while the subscribers are not active. Durable subscriptions provide the flexibility and reliability of queues but still allow clients to send messages to many recipients. For more information about durable subscriptions, see Creating Durable Subscriptions.

This is where we use javax.jms.Session.createDurableSubscriber :

The JMS provider retains a record of this durable subscription and insures that all messages from the topic's publishers are retained until they are acknowledged by this durable subscriber or they have expired.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM