background image

The Terminal Window

<< The Non-Text Control Message | Browsing Messages in a Queue >>
<< The Non-Text Control Message | Browsing Messages in a Queue >>

The Terminal Window

To run the clients using the appclient command, follow these steps:
1. Run the AsynchConsumer program, specifying the topic destination type.
cd dist
appclient -client asynchconsumer.jar topic
The program displays the following lines and appears to hang:
Destination type is topic
To end program, type Q or q, then <return>
2. In the terminal window where you ran the Producer program previously, run the program
again, sending three messages. The command looks like this:
appclient -client producer.jar topic 3
The output of the program looks like this:
Destination type is topic
Sending message: This is message 1
Sending message: This is message 2
Sending message: This is message 3
In the other window, the AsynchConsumer program displays the following:
Destination type is topic
To end program, type Q or q, then <return>
Reading message: This is message 1
Reading message: This is message 2
Reading message: This is message 3
Message is not a TextMessage
The last line appears because the program has received the non-text control message sent by
the Producer program.
3. Type Q or q and press Return to stop the program.
4. Now run the programs using a queue. In this case, as with the synchronous example, you
can run the Producer program first, because there is no timing dependency between the
sender and receiver:
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
Writing Simple JMS Client Applications
Chapter 31 · The Java Message Service API
925