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 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.