background image

The Producer Project

<< Running the Clients | The appclient Command >>
<< Running the Clients | The appclient Command >>

The Producer Project

a. Right-click the producer project and choose Properties.
b. Select Run from the Categories tree.
c. In the Arguments field, type the following:
topic 3
d. Click OK.
e. Right-click the project and choose Run Project.
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
6. Now run the SynchConsumer example using the topic.
a. Right-click the synchconsumer project and choose Properties.
b. Select Run from the Categories tree.
c. In the Arguments field, type the following:
topic
d. Click OK.
e. Right-click the project and choose Run Project.
The result, however, is different. Because you are using a topic, messages that were sent
before you started the consumer cannot be received. (See
"Publish/Subscribe Messaging
Domain" on page 899
, for details.) Instead of receiving the messages, the program
appears to hang.
7. Run the Producer example again. Right-click the producer project and choose Run Project.
Now the SynchConsumer example receives the messages:
Destination type is topic
Reading message: This is message 1
Reading message: This is message 2
Reading message: This is message 3
You can also run the sample programs using the appclient command. Each of the programs
takes one or more command-line arguments: a destination type and, for Producer, a number of
messages.
Writing Simple JMS Client Applications
The Java EE 5 Tutorial · September 2007
918