1

I am consuming messages from IBM Mq using message driven channel adapter (Spring Integration) . JMS Destination property in the message is coming as null. Could someone tell me how to get queue name in header for messages consumed using wmq.
JMS Destination property is coming for messages consumed from apache Active mq but not for IBM MQ.

user6543599
  • 541
  • 2
  • 8
  • 18

1 Answers1

0

The DefaultJmsHeaderMapper has the code like this:

 try {
        Destination destination = jmsMessage.getJMSDestination();
        if (destination != null) {
            headers.put(JmsHeaders.DESTINATION, destination);
        }
    }
    catch (Exception ex) {
        this.logger.info("failed to read JMSDestination property, skipping", ex);
    }

So, if IBM Mq doesn't provide that property value, we really won't have a JmsHeaders.DESTINATION header on the matter.

I suggest you to investigate all the headers you get after consuming and see what one may have a required destination for you.

Otherwise you always can extend DefaultJmsHeaderMapper and implement your own logic in the overridden toHeaders() method.

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118
  • I have tried jmsMessage.getJMSDestination() which is returning null as well. I have inspected all the headers which doesn't have queue information. – user6543599 May 18 '18 at 16:39
  • Right. That's what I'm explaining why you don't get the value in the `JmsHeaders.DESTINATION` and I suggest you the way to go. What am I missing, please? – Artem Bilan May 18 '18 at 16:40
  • Thanks for you reply. Does extending DefaultJmsHeaderMapper can solve my issue? Can i get my queue name in the overridden toHeaders() method? – user6543599 May 18 '18 at 16:46
  • Do you not know by context what queue you are reading from? You had to specify the queue name to open it and read messages. – JoshMc May 18 '18 at 16:51
  • I would be consuming a lot queues and passing to a common channel. I would not be knowing the queue name in my channel. – user6543599 May 18 '18 at 16:54
  • You need to consult with IBM to determine in what `JmsMessage` property they populate a `Destination`. And then use that property in the `DefaultJmsHeaderMapper` extension, e.g. call `super.toHeaders()`, check if `JmsHeaders.DESTINATION` header is null and populate a destination from that IBM property. Does it make sense to you? – Artem Bilan May 18 '18 at 16:57