background image

The appclient Command

<< The Producer Project | Asynchronous Message Consumption >>
<< The Producer Project | Asynchronous Message Consumption >>

The appclient Command

To run the clients using the appclient command, follow these steps:
1. In a terminal window, go to the producer/dist directory:
cd ../producer/dist
2. Run the Producer program, sending three messages to the queue:
appclient -client producer.jar queue 3
The output of the program looks like this:
Destination type is queue
Sending message: This is message 1
Sending message: This is message 2
Sending message: This is message 3
The messages are now in the queue, waiting to be received.
3. In the same window, go to the synchconsumer/dist directory:
cd ../../synchconsumer/dist
4. Run the SynchConsumer program, specifying the queue:
appclient -client synchconsumer.jar queue
The output of the program looks like this:
Destination type is queue
Reading message: This is message 1
Reading message: This is message 2
Reading message: This is message 3
5. Now try running the programs in the opposite order. Run the SynchConsumer program. It
displays the destination type and then appears to hang, waiting for messages.
appclient -client synchconsumer.jar queue
6. In a different terminal window, run the Producer program.
cd
tut-install/javaeetutorial5/examples/jms/simple/producer/dist
appclient -client producer.jar queue 3
When the messages have been sent, the SynchConsumer program receives them and exits.
7. Now run the Producer program using a topic instead of a queue:
appclient -client producer.jar topic 3
The output of the program looks like this:
Writing Simple JMS Client Applications
Chapter 31 · The Java Message Service API
919