title: Apache Camel -- Websphere MQ integration
body: <p>I have an application using apache-camel solution, and would like to send message to Websphere MQ Server through jms, convert jms property <code>JMS_IBM_MQMD_MsgId</code> to MQMD field <code>MQMD.MsgId</code>, so that I set this value on message through camel</p>
  
  <pre><code>exchange.getIn().setHeader(WMQConstants.JMS_IBM_MQMD_MSGID, "XXXXXXXXXXXXXXXXXXXXXXXX".getBytes());
  </code></pre>
  
  <p>According to <a href="https://stackoverflow.com/questions/45962569/apache-camel-ibm-mq-integration/45966114#45966114">Apache Camel - IBM MQ integration</a>, seems we need another properties setting on destination object. Reference <strong>Setting JMS Provider Options on the Destination</strong> on <a href="http://camel.apache.org/jms.html" rel="nofollow noreferrer">http://camel.apache.org/jms.html</a>, I provide a custom DestinationResolver for camel jms component, set <code>mdWriteEnabled</code>, <code>mdReadEnabled</code> for destination object.</p>
  
  <pre><code>&lt;bean id="ibmMQServer01" class="org.apache.camel.component.jms.JmsComponent"&gt;
      &lt;property name="connectionFactory" ref="ibmMQCredentialConnectionFactory01" /&gt;
      &lt;property name="destinationResolver" ref="wmqDestinationResolver" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>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;
      }
  }
  </code></pre>
  
  <p>I can get <code>JMS_IBM_MQMD_MsgId</code> on receiver while setting <code>mdReadEnabled</code> equals true. However, <code>mdWriteEnabled</code> seems not works for me, and I get <code>JMS_IBM_MQMD_MsgId</code> as an unexpected value <code>AMQ CS.QA.CBSA.Q�Y�b</code> (been parsed from byte[], totally 24 bytes).</p>
  
  <p>The received <code>JMSMessageID</code> is <code>ID:414d512043532e51412e434253412e511987055902cc6222</code>, which can be parsed to the messy string above.</p>