Publish/Subscribe Messaging Example
Now, you will build a simple bulletin board application. For this example, the bulletin board publisher program will generate 10 simple messages. The subscriber will be a Swing application that will display the messages as they arrive.
The bulletin board uses a topic called jms/bulletinBoard created along with the other JMS resources at the start of today's examples.
Bulletin Board Publisher
The same mechanism is used to create a topic as you used to create a queue, so Listing 9.4 should appear very similar to the previous point-to-point sender example.
Listing 9.4. Bulletin Board Publisher BBPublisher.java
import javax.jms.*; public class BBPublisher { private Connection connection; private Session session; ... |
Get Sams Teach Yourself J2EE™ in 21 Days, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.