...
durableTopicSubscriber
is run to create a durable topic subscriber.- 5 messages are sent to the
myTopic
topic. The messages will be received and printed by the subscriber nameddurableTopicSubscriber
. - The
durableTopicSubscriber
is stopped. - The publisher is run again and 5 more messages are sent.
- While running
durableTopicSubscriber
again, 5 different messages are sent to the same topic. You will see that all 10 messages (including the messages sent to the topic when the subscriber was absent) are consumed by thedurableTopicSubscriber
. - 200 more messages are sent.
durableTopicSubscriber
will close after 100 messages are received. After runningdurableTopicSubscriber
again you will receive nothing (as durableTopicSubscriber was unsubscribed after receiving 100 messages).