Java Reference
In-Depth Information
sage 2
SUBSCRIBER: Processing message: Here is an auto-acknowledge mes-
sage 1
PUBLISHER: Publishing message: Here is an auto-acknowledge mes-
sage 3
SUBSCRIBER: Processing message: Here is an auto-acknowledge mes-
sage 2
SUBSCRIBER: Processing message: Here is an auto-acknowledge mes-
sage 3
5. After you run the client, you can delete the destination resource
jms/Con-
trolQueue
by using the following command:
asadmin delete-jms-resource jms/ControlQueue
You will need the other resources for other examples.
A Durable Subscription Example
DurableSubscriberExample.java
shows how durable subscriptions work. It
demonstrates that a durable subscription is active even when the subscriber is not active.
The example contains a
DurableSubscriber
class, a
MultiplePublisher
class,
a
main
method, and a method that instantiates the classes and calls their methods in se-
quence.
The example is in the
tut-install
/examples/jms/advanced/durablesubscriberexample/
src/java/
directory.
The example begins in the same way as any publish/subscribe client: The subscriber starts,
the publisher publishes some messages, and the subscriber receives them. At this point,
the subscriber closes itself. The publisher then publishes some messages while the sub-
scriber is not active. The subscriber then restarts and receives those messages.
You can use either NetBeans IDE or Ant to build, package, deploy, and run
durable-
subscriberexample
.
To Run
durablesubscriberexample
Using NetBeans IDE
1. To compile and package the client, follow these steps:
a. From the File menu, choose Open Project.
b. In the Open Project dialog, navigate to:
tut-install
/examples/jms/advanced/