background image

Running the MessageBrowser Client

<< Compiling the MessageBrowser Client | The Producer/Dist Directory >>
<< Compiling the MessageBrowser Client | The Producer/Dist Directory >>

Running the MessageBrowser Client

To compile and package the MessageBrowser example using Ant, follow these steps:
1. In a terminal window, go to the messagebrowser directory. If you are currently in the
asynchconsumer/dist
directory, you need to go up two levels:
cd ../../messagebrowser
2. Type the following command:
ant
The targets place the application client JAR file in the dist directory for the example.
You also need the Producer example to send the message to the queue, and one of the consumer
programs to consume the messages after you inspect them. If you did not do so already, package
these examples.
Running the Clients for the Queue Browser Example
To run the programs using NetBeans IDE, follow these steps.
1. Run the Producer program, sending one message to the queue:
a. Right-click the producer project and choose Properties.
b. Select Run from the Categories tree.
c. In the Arguments field, type the following:
queue
d. Click OK.
e. Right-click the project and choose Run Project.
The output of the program looks like this:
Destination type is queue
Sending message: This is message 1
The first message is the TextMessage, and the second is the non-text control message.
2. Run the MessageBrowser program. Right-click the messagebrowser project and choose
Run Project.
The output of the program looks like this:
Message:
Text: This is message 1
Class: com.sun.messaging.jmq.jmsclient.TextMessageImpl
getJMSMessageID(): ID:12-129.148.71.199(8c:34:4a:1a:1b:b8)-40883-1129062957611
getJMSTimestamp(): 1129062957611
getJMSCorrelationID(): null
Writing Simple JMS Client Applications
The Java EE 5 Tutorial · September 2007
928