Two pub/sub programs are available in the Appendix -- Code listing for TPublisher.java and Code listing for TSubscriber.java. We won't go through them step-by-step as we did the PTP programs because, other than the types of JMS interfaces used, they are identical to QSender.java and QReceiver.java.
You need to set up
Topic administered objects before you run these programs.
You'll see the difference between these and the PTP programs once you run them. If you run multiple instances of
QReceiver using the same
you'll see that as you send messages from
only one of the
QReceiver instances receives each message sent.
If you run multiple instances of
you'll see that all messages sent from
TPublisher are received by all instances of