Durable Versus Nondurable Subscribers
If you were to run the
TBorrower class and then publish
several rates, the TBorrower class
would pick up the new rate and make a determination as to whether it was
a good rate or not. However, if you were to terminate the TBorrower class, publish some new rates, then
restart the TBorrower class, you
would not have picked up the rates that were published to the topic
while the TBorrower class was not
running. Why? Because the TBorrower
class was created as a nondurable subscriber:
TopicSubscriber subscriber = tSession.createSubscriber(topic);
Nondurable subscribers receive messages only when they are actively listening on that topic. Otherwise, the message is gone. In the pub/sub model, there is no real concept of a “topic” holding all of the messages; rather, when a message is received by the JMS provider, the provider makes a copy of that message for each subscriber. If the subscriber is not active, it does not receive a copy of that message. This concept is illustrated in Figure 5-3.

Figure 5-3. Nondurable subscribers
Durable subscribers, on the other hand, will receive all messages sent to that topic (depending on the message selectors applied to that subscriber), regardless of whether that subscriber is active or not. This is commonly referred to as “store-and-forward” messaging. Email is a good example of this concept, even though email is usually ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access