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