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(); ...

Get J2EE™ Applications and BEA™ WebLogic Server™ now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.