Chapter 23
886
Running the Pub/Sub Examples
Here are the instructions to run the Pub/Sub examples. Compile the two files Publisher.java and
Subscriber.java, and run a Publisher and any number of Subscribers:
Messages you type in the Publisher window will be sent to MyJMSTopic and you will see them show up
as received messages in the Subscriber window. All Subscribers on MyJMSTopic will receive all
messages posted to the topic:
Type in q or Q to exit both the Publisher and any active Subscribers.
The Point-to-Point Messaging Model
PTP is a one-to-one messaging model. One message producer sends a message to a queue and only one
message consumer receives the message from the queue. In order to speed up message processing, a
developer might create more than one client to listen on the same queue, but only one of them will
receive any particular message sent to the queue:
Message Sender
Send a message
Queue
Receive a message
Message Recipient