I have a Apache camel (version 2.18) project that sends a file to my partner's IBM MQ server by IBM MQ client. However, my partner uses the messageId
as the filename, thus, we have to set specific filename tomessageId
.
My question is how we can change the messageId
?
I tried to add JMS_IBM_MQMD_MsgId
or MsgId
or modify the JMSMessageId
in JMS header before I send the file to the IBM MQ server, but it doesn't work.
Do you have any solution?
Here is the code in spring file. For example, before we send JMS to my partner's server. We set the below key/value to JMS header:
exchange.getIn().setHeader("JMS_IBM_MQMD_MsgId",MsgExtFileName().getBytes())
exchange.getIn().setHeader("JMS_IBM_Format", MQC.MQFMT_STRING)
IBM MQ v8 Knowledge center documents how to set MQMD properties with IBM MQ Classes for JMS in the page "Reading and writing the message descriptor from an IBM MQ classes for JMS application"
The IBM MQ v8 Knowledge center page "JMS message object properties" documents the properties that can set be set.
I am a IBM MQ admin and not versed in Apache Camel, but I found this StackOverflow post "How to set ApplicationIdData using MQQueueConnectionFactory?" helpful along with the Apache Camel Documentation on "Simple Expression Language"
Based on the above information you just need to add one additional line to allow you to set the JMS_IBM_MQMD_MsgId peroperty:
NOTE based on some other info I found the setHeader above may not be correct and you may need to append it to the end of your Queue destination URI:
Note that the messageId in the IBM MQ MQMD is represented as 24 bytes. This not not converted when passed from platform to platform, if you are using normal alpha numeric characters this should not be a problem even going from UTF-8 to ASCII since the byte values are the same, but it is something to be aware of.
For more information on messageId and character sets reference these two StackOverflow answers:
Get MQ messageId in string format
CCSID on MQ Managers on different platforms