10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>The</strong> output of the program looks like this:<br />

Destination type is queue<br />

Sending message: This is message 1<br />

Sending message: This is message 2<br />

Sending message: This is message 3<br />

5. Run the AsynchConsumer program.<br />

a. Right-click the asynchconsumer project and choose Properties.<br />

b. Select Run from the Categories tree.<br />

c. In the Arguments field, type the following:<br />

queue<br />

d. Click OK.<br />

e. Right-click the project and choose Run.<br />

<strong>The</strong> output of the program looks like this:<br />

Destination type is queue<br />

To end program, type Q or q, then <br />

Reading message: This is message 1<br />

Reading message: This is message 2<br />

Reading message: This is message 3<br />

Message is not a TextMessage<br />

6. Type Q or q in the Output window and press Return to stop the program.<br />

To run the clients using the appclient command, follow these steps:<br />

1. Run the AsynchConsumer program, specifying the topic destination type.<br />

cd dist<br />

appclient -client asynchconsumer.jar topic<br />

<strong>The</strong> program displays the following lines and appears to hang:<br />

Destination type is topic<br />

To end program, type Q or q, then <br />

2. In the terminal window where you ran the Producer program previously, run the program<br />

again, sending three messages. <strong>The</strong> command looks like this:<br />

appclient -client producer.jar topic 3<br />

<strong>The</strong> output of the program looks like this:<br />

Destination type is topic<br />

Sending message: This is message 1<br />

Sending message: This is message 2<br />

Sending message: This is message 3<br />

In the other window, the AsynchConsumer program displays the following:<br />

Writing Simple JMS Client Applications<br />

Chapter 31 • <strong>The</strong> <strong>Java</strong> Message Service API 919

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!