Question

I have below pseudo code of flow which uses queue to send the message and then listen to topic synchronously. The underlying JMS provider is Tibco EMS.

//Send to Queue
Connection connection = createConnection(); // get the JMS connection
Session session = connection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue("sample.queue");
MessageProducer messageProducer =  session.createProducer(queue);
Message message = createMessage(); //create JMS message
messageProducer.send(message);

Now, I listen to a topic using same session object created and wait till there is a response.

Topic topic = session.createTopic("sample.topic");
MessageConsumer messageConsumer =  session.createConsumer(topic);
//wait for the reply.
Message responseMessage = messageConsumer.receive(60000);
if(responseMessage != null) {
    System.out.println("Message received..");
}

The problem that I am facing is that the message object is coming out as null. I tested with a jms monitoring tool and the topic does have some message, but the above code is not able to pick it up even after 60 secs.

Any idea what am I missing here ?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top