O'Reilly logo

Sams Teach Yourself J2EE™ in 21 Days by Peter Roxburgh, Andy Longshaw, Debbie Law, Dan Haywood, Martin Bond

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Publish/Subscribe Message Domain

So far, you have seen how to create a simple point-to-point application with a single sender and receiver. Now you will build a simple bulletin board application to demonstrate the features of the publish/subscribe model.

For this example, a TopicPublisher will be produced that creates messages and publishes them to a bulletin board. A single TopicSubscriber will asynchronously listen for messages. The messages will be printed to the screen—one at time—in the order they were received. The program then exits.

Remember that, unlike messages in a queue, messages in a topic are immediately distributed to all subscribers. As a result, the timing of the publisher and the subscriber becomes important. Apart from ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required