I have an application using apache-camel solution, and would like to send message to Websphere MQ Server through jms, convert jms property JMS_IBM_MQMD_MsgId
to MQMD field MQMD.MsgId
, so that I set this value on message through camel
exchange.getIn().setHeader(WMQConstants.JMS_IBM_MQMD_MSGID, "XXXXXXXXXXXXXXXXXXXXXXXX".getBytes());
According to Apache Camel - IBM MQ integration, seems we need another properties setting on destination object. Reference Setting JMS Provider Options on the Destination on http://camel.apache.org/jms.html, I provide a custom DestinationResolver for camel jms component, set mdWriteEnabled
, mdReadEnabled
for destination object.
<bean id="ibmMQServer01" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory" ref="ibmMQCredentialConnectionFactory01" />
<property name="destinationResolver" ref="wmqDestinationResolver" />
</bean>
and
public class WMQDestinationResolver implements DestinationResolver {
@Override
public Destination resolveDestinationName(Session session, String destinationName,
boolean pubSubDomain) throws JMSException {
MQSession mqSession = (MQSession) session;
MQQueue queue = (MQQueue) mqSession.createQueue("queue:///" + destinationName);
queue.setBooleanProperty(WMQConstants.WMQ_MQMD_WRITE_ENABLED, true);
queue.setBooleanProperty(WMQConstants.WMQ_MQMD_READ_ENABLED, true);
queue.setIntProperty(WMQConstants.WMQ_MQMD_MESSAGE_CONTEXT, WMQConstants.WMQ_MDCTX_SET_ALL_CONTEXT);
return queue;
}
}
I can get JMS_IBM_MQMD_MsgId
on receiver while setting mdReadEnabled
equals true. However, mdWriteEnabled
seems not works for me, and I get JMS_IBM_MQMD_MsgId
as an unexpected value AMQ CS.QA.CBSA.Q�Y�b
(been parsed from byte[], totally 24 bytes).
The received JMSMessageID
is ID:414d512043532e51412e434253412e511987055902cc6222
, which can be parsed to the messy string above.