Nov 11th, 2008, 03:01 PM
how to get the JMS queue name from within a POJO message bean?
Our JMS integration with Spring follows the common path of having a DefaultMessageListenerContainer -> MessageListenerAdapter -> POJO.
The POJO is used for multiple destinations. I would like to know, inside the POJO, where the message came from. The directly available data doesn't contain this piece of information, the only method on the POJO is public void handleMessage(Object message).
How can I retrieve the queue name, though? Is there any support in Spring I am not aware of? I searched in "Spring in Action", but didn't find an answer.
Nov 11th, 2008, 10:46 PM
As long as the JMS headers are intact, you should be able to grab the destination name from the JMSDestination property on the message.
Nov 13th, 2008, 09:03 AM
I think this should work
String queueNm = ((ActiveMQQueue)jmsMsg.getJMSDestination)).getPhys icalName();
and for topic
String topic = ((ActiveMQTopic)jmsMsg.getJMSDestination()).getTop icName();