There are a few properties that you need to set in Apache Camel before you can set the JMS_IBM_MQMD_MsgId
header. Since these headers are in byte[] format, JMS does not natively support values apart from primitive data types and String.
You can setup a DestinationResolver to add a few properties in the IBM MQ queue. Since these properties are not jms component properties, they have to be set via CustomDestinationResolver. Refer this link.
public DestinationResolver mqmdWriteEnabledWmqDestinationResolver() {
return new DestinationResolver() {
@Override
public Destination resolveDestinationName(
Session session, String destinationName, boolean pubSubDomain) throws JMSException {
MQSession wmqSession = (MQSession) session;
MQQueue queue = (MQQueue) wmqSession.createQueue("queue:///" + destinationName);
queue.setMQMDWriteEnabled(true);
return queue;
}
};
}
setMQMDWriteEnabled
will let you write MQMD headers like JMS_IBM_MQMD_MsgId
, which do not match the JMS specifications.
However, do note that by default, destinationResolvers are autowired, so you may need to create a new default destination resolver if you are using camel with spring boot.
You can then generate the JMS_IBM_MQMD_MsgId
as a byte[] of the message id. Refer to docs for the MessageId standards of IBM MQ.
Once you do that, this will be the configuration of your to endpoint:
.to(
jms("queue:DEV.QUEUE.1")
.connectionFactory(connectionFactory)
.preserveMessageQos(true)
.advanced()
.destinationResolver(mqmdWriteEnabledWmqDestinationResolver)
.allowAdditionalHeaders("JMS_IBM_MQMD_.*"))
allowAdditionalHeaders
will allow non JMS headers to be sent to the destination.