1
votes

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

2

2 Answers

1
votes

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.

0
votes

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.