O'Reilly logo

J2EE™ Applications and BEA™ WebLogic Server™ by Sandra L. Emerson, Rob Woollen, Michael Girdley

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

Sample JMS Topic Producer/Consumer

The JMS topic example demonstrates publishing messages to a "MessageTopic" and synchronous and asynchronous message consumers. Because this is a topic, both consumers can run simultaneously and receive each message.

Message Producer

Like the JMS queue examples, the topic message producer begins by using JNDI to look up the ConnectionFactory and JMS destination. This example uses the standard JMS ConnectionFactory, so it looks up "weblogic.jms.ConnectionFactory".

 Context ctx = getInitialContext(); TopicConnectionFactory tConFactory = (TopicConnectionFactory) ctx.lookup("weblogic.jms.ConnectionFactory"); Topic messageTopic = (Topic) ctx.lookup("MessageTopic"); TopicConnection tCon = tConFactory.createTopicConnection(); ...

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