Reputation: 171
When consuming a javax.jms.Message from IBM MQ I want to log the message id and destination it came from like this:
Received [ID:...] from [...]
For some messages this works fine and looks like this:
Received [ID:414d5120465030303030374920202020a948b66401d61440] from [queue://MYQMGR/MYQ]
But for some other queues on the same queue manager Message.getJMSDestination() returns null, and I get this:
Received [ID:414d512053415a324d5131452020202063c3b3fc9c229718] from [null]
Details about my context:
Upvotes: 0
Views: 508
Reputation: 4737
I guess that you are using logic akin to
try {
Destination jmsDestination = message.getJMSDestination();
if (jmsDestination != null) {
q = ((Queue) jmsDestination).getQueueName();
System.out.println(formatTime() + " JMS message received by from queue: " + q);
} else {
System.out.println(formatTime() + " MQ message received");
}
} catch (JMSRuntimeException | JMSException e) {
msgErr = " ERROR: JMS error getting destination: " + e.getLocalizedMessage();
throw new RuntimeException(msgErr, e);
}
In which case a null destination indicates that the message didn't come from a JMS application. IE. if the sender application was a Node.js making use of the MQI API then you would expect to see JMSDestination as null.
Upvotes: 0