JMS Publish-Subscribe Operations: Handling Messages with No Available Subscribers

What Happens When There Are No Subscribers for a Topic with a Durable Subscription?

Question

You are working with JMS publish-subscribe operations.

What happens when a producer publishes a message to a topic for which a durable subscription exists but there are no subscribers available?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

C.

https://www.ibm.com/support/knowledgecenter/en/SSAW57_8.5.5/com.ibm.websphere.nd.multiplatform.doc/ae/tjn0012_.html

When a producer publishes a message to a JMS topic, the message is delivered to all active subscribers who have created a durable subscription for that topic. A durable subscription allows a subscriber to receive messages sent to a topic even if the subscriber is not currently active.

In the case where a producer publishes a message to a topic for which a durable subscription exists, but there are no active subscribers available, the behavior of the JMS provider depends on the delivery mode of the message and the configuration of the durable subscription.

If the message has been sent with a non-persistent delivery mode, the JMS provider may discard the message if there are no active subscribers available. This behavior is non-deterministic and depends on the specific JMS provider implementation.

If the message has been sent with a persistent delivery mode, the message will be stored on the JMS provider until an active subscriber becomes available. The message will be kept until the message's expiration time is reached or until it is consumed by an active subscriber.

In both cases, the JMS provider will not immediately notify the publisher of the lack of subscribers. Instead, the JMS provider will store the message and wait for an active subscriber to become available.

If a message has a time-to-live (TTL) set, it will be considered expired and discarded by the JMS provider if it is not consumed by an active subscriber before the TTL is reached.

In the case of a durable subscription, a subscriber can become active at any time, and when it does, it will receive any messages that were published to the topic while it was inactive. The subscriber must specify the same durable subscription name that was used when creating the subscription to receive these messages.

In summary, when a producer publishes a message to a topic for which a durable subscription exists but there are no active subscribers available, the JMS provider will store the message and wait for an active subscriber to become available. The publisher will not be immediately notified of the lack of subscribers, and the behavior of the JMS provider depends on the delivery mode of the message and the configuration of the durable subscription.