Nondurable Subscribers and Subscriptions
Nondurable Subscribers and Subscriptions
subscription also ends. Here, create stands for a call to Session.createConsumer with a Topic
argument, and close stands for a call to MessageConsumer.close. Any messages published to
the topic between the time of the first close and the time of the second create are not
consumed by the subscriber. In
, the subscriber consumes messages M1, M2, M5,
and M6, but messages M3 and M4 are lost.
With a durable subscriber, the subscriber can be closed and re-created, but the subscription
continues to exist and to hold messages until the application calls the unsubscribe method. In
, create stands for a call to Session.createDurableSubscriber, close stands for
a call to MessageConsumer.close, and unsubscribe stands for a call to Session.unsubscribe.
Messages published while the subscriber is closed are received when the subscriber is created
again. So even though messages M2, M4, and M5 arrive while the subscriber is closed, they are
not lost.
See
for an
example of a Java EE application that uses durable subscriptions. See
and the next section for examples of client
applications that use durable subscriptions.
Subscriber
Subscription
create
close
Subscriber
Subscription
create
close
M1
M2
M3
M4
M5
M6
FIGURE 317
Nondurable Subscribers and Subscriptions
Subscriber
create
close
M1
M2
M3
M4 M5
M6
Subscriber
create
close
Subscriber
create
close
create
unsubscribe
FIGURE 318
A Durable Subscriber and Subscription
Creating Robust JMS Applications
The Java EE 5 Tutorial · September 2007
944