O'Reilly logo

Distributed Computing in Java 9 by Raja Malleswara Rao Pattamsetti

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

Publish-Subscribe (topic) programming

As discussed in the previous sections, interfaces extending core JMS interfaces for Topic help build publish-subscribe components.

Please remember that, to be able to execute the following example programs, you need the message queue environment.

The following is a sample program to publish messages to the Publish-Subscribe topic:

package pubsub;import java.io.BufferedReader;import java.io.InputStreamReader;import javax.jms.Session;import javax.jms.TextMessage;import javax.jms.Topic;import javax.jms.TopicConnection;import javax.jms.TopicConnectionFactory;import javax.jms.TopicPublisher;import javax.jms.TopicSession;import javax.naming.InitialContext;/*** Program to publish messages to the topic* @author ...

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