Setting ApplIdentityData on a Liberty Profile defined queue

Setting the necessary properties on the Java Client for MQ libraries in order to pass the ApplIdentityData is quiet simple, as mentioned in this stackoverflow post:
MQDestination queue;
queue.setBooleanProperty(WMQConstants.WMQ_MQMD_WRITE_ENABLED, true);
queue.setBooleanProperty(WMQConstants.WMQ_MQMD_READ_ENABLED, true);
javax.jms.Message message;
message.setStringProperty(JmsConstants.JMS_IBM_MQMD_APPLIDENTITYDATA, "....");

The meaning of the properties is listed in the documentation: Destination object properties.

If using Websphere Application Server, you can define a Jms Queue as a Resource which can be intern looked up via JNDI. IBM has a pretty good summary of the different methods.
How to read and write fields from the MQMD via WebSphere MQ Classes for JMS Version 7: direct, using JNDI and using WebSphere Application Server.

To set it up in WAS7 for instance:
  • From the admin console
  • Resources/JMS/Queues
  • Select the scope you want to use from the drop down (i.e. Cluster=MYCLUSTER)
  • New
  • "WebSphere MQ messaging provider"
  • Name: any name you want
    JNDI Name: the jndi path you'll look it up via, i.e. jms/SendQ
    Queue name: the name of the queue on the queue manager
  • Apply
  • Advanced properties
    Uncheck "Append RFH version 2 headers to messages sent to this destination" to send raw MQ messages instead of JMS messages (with a JMS header)
  • Custom properties
    • Add name=MDR value=YES Description=WMQ_MQMD_READ_ENABLED Type=String
    • Add name=MDW value=YES Description=WMQ_MQMD_WRITE_ENABLED Type=String
    • Add name=MDCTX value=SET_IDENTITY_CONTEXT Description=WMQ_MQMD_MESSAGE_CONTEXT Type=String
  • Save
However in Websphere Liberty Profile the options are different. Here is a sample server.xml:
<server description="Sample MQ Server">

 <!-- Enable features -->
 <featuremanager onerror="WARN">

 <jmsqueueconnectionfactory jndiname="jms/qcf">
  <properties.wmqjms channel="MYCHANNEL" hostname="THEHOST" queuemanager="THEQUEUEMANAGER" transporttype="CLIENT"/>

 <jmsqueue id="qSend" jndiname="jms/SendQ">
  <properties.wmqjms arbitraryproperties='MDR="YES", MDW="YES", MDCTX="2"' basequeuename="MESSAGE.OUTBOUND" targetclient="MQ"/>

 <variable name="wmqJmsClient.rar.location" value="${shared.resource.dir}/wmq/wmq.jmsra.rar"/>

 <!-- -->
 <webcontainer deferservletload="false"/>
If your using camel you would wire it up thus:
<beans xmlns:jee="" xmlns:xsi="" xmlns="" xsi:schemalocation="">

    <jee:jndi-lookup id="connectionFactory" jndi-name="jms/qcf"/>

    <bean class="org.apache.camel.component.jms.JmsComponent" id="jms">
        <property name="connectionFactory" ref="connectionFactory"/>
        <property name="destinationResolver" ref="jmsDestinationResolver"/>

    <bean class="" id="jmsDestinationResolver">
        <property name="jndiTemplate" ref="jndiTemplate"/>

    <bean class="org.springframework.jndi.JndiTemplate" id="jndiTemplate"/>

And finally the route:
        .setHeader("JMS_IBM_MQMD_ApplIdentityData", constant("USERNAMEPASSWORD"))


Post a Comment