Results 1 to 9 of 9

Thread: JMS Outbound Channel Adapter + IBM MQ Issue

  1. #1

    Default JMS Outbound Channel Adapter + IBM MQ Issue

    I am using Spring Integration 1.0.4 release and reading a XML message from Active MQ, transforming it using XSL to another XML and send this to IBM MQ which is then picked up by another process but that process fails as it gets invalid characters in the message XML.

    The spring program is running on Windows machine, Active MQ is on Windows machine and the IBM MQ machine is on Solaris.

    I am able to send messages proeprly through standalone JAVA program as below -

    import com.ibm.mq.MQC;
    import com.ibm.mq.MQEnvironment;
    import com.ibm.mq.MQMessage;
    import com.ibm.mq.MQPutMessageOptions;
    import com.ibm.mq.MQQueue;
    import com.ibm.mq.MQQueueManager;

    MQQueueManager queueManager = null;
    MQQueue queue = null;

    try {
    MQEnvironment.hostname = "somehost";
    MQEnvironment.port = 1414;
    MQEnvironment.channel = "SYSTEM.DEF.SVRCONN";
    MQEnvironment.properties.put(MQC.TRANSPORT_PROPERT Y, MQC.TRANSPORT_MQSERIES);

    queueManager = new MQQueueManager("qmgr");

    int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT;
    queue = queueManager.accessQueue("queue.output", openOptions, null, null, null);

    MQMessage message = new MQMessage();
    MQPutMessageOptions messageOptions = new MQPutMessageOptions();
    message.writeUTF("<message></message>");
    queue.put(message, messageOptions);
    } catch (Exception e) {
    e.printStackTrace();
    } finally {
    queue.close();
    queueManager.disconnect();
    }

    The string added to the actual transformed XML are as below which is giving problem -
    RFH ^B^A^D^A^Q^C3MQSTR ^D? <mcd><Msd>jms_text</Msd></mcd> X<jms><Dst>queue:///SMO.TXN.FROM.TREASURY</Dst><Tms>1283839569762</Tms><Dlv>2</Dlv></jms>\<usr><s
    pringintegration_timestamp dt='i8'>1283839567402</springintegration_timestamp></usr> ....then the XML comes

    The spring configuration is as below -

    <bean id="inputConnectionFactory" class="org.springframework.jms.connection.CachingC onnectionFactory">
    <property name="targetConnectionFactory">
    <bean class="org.apache.activemq.ActiveMQConnectionFacto ry">
    <property name="brokerURL" value="tcp://localhost:61616"/>
    </bean>
    </property>
    <property name="sessionCacheSize" value="10"/>
    <property name="cacheProducers" value="false"/>
    </bean>

    <bean id="inputQueue" class="org.apache.activemq.command.ActiveMQQueue">
    <constructor-arg value="queue.input"/>
    </bean>

    <bean id="outputConnectionFactory" class="org.springframework.jms.connection.CachingC onnectionFactory">
    <property name="targetConnectionFactory">
    <bean class="com.ibm.mq.jms.MQQueueConnectionFactory">
    <property name="hostName" value="somehost"/>
    <property name="port" value="1414"/>
    <property name="channel" value="SYSTEM.DEF.SVRCONN"/>
    <property name="queueManager" value="qmgr"/>
    <property name="transportType" value="1"/>
    </bean>
    </property>
    <property name="sessionCacheSize" value="10"/>
    <property name="cacheProducers" value="false"/>
    </bean>

    <bean id="outputQueue" class="com.ibm.mq.jms.MQQueue">
    <constructor-arg value="queue.output"/>
    </bean>

    <jms:message-driven-channel-adapter
    destination="inputQueue"
    connection-factory="inputConnectionFactory"
    channel="jmsInChannel" />

    <channel id="jmsInChannel" />

    <channel id="jmsOutChannel" />

    <si-xml:xslt-transformer input-channel="jmsInChannel" output-channel="jmsOutChannel" xsl-resource="classpath:transform.xsl" />

    <jms:outbound-channel-adapter
    connection-factory="outputConnectionFactory"
    destination="outputQueue"
    channel="jmsOutChannel"/>

    Let me know what I need to do to avoid the junk characters in the message to IBM MQ.

  2. #2
    Join Date
    Nov 2008
    Location
    Swansea, Wales
    Posts
    202

    Default

    Are you using WAS? if so, I forget what the property is called exactly but what is your queue type defined as in your JMS setup in WAS? The options are either JMS or MQ. I had similar problems with the queue type set to MQ but setting it to JMS fixed it

  3. #3

    Default

    I do not know the setup of application which is listening to MQ as it is another system. I am running my spring code standalone using ClassPathXmlApplicationContext from a main method and I have com.ibm.mqjms.jar in my classpath.

  4. #4

    Default

    Anyone has any solution to this?

  5. #5
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,840

    Default

    This looks like a mirror image of the problem you posted here:
    http://forum.springsource.org/showthread.php?t=95347

    Can you verify that you are setting the correct int value for 'transportType'?

  6. #6

    Default

    The transportType value being used 1 is the correct value which is same as the value of JMSC.MQJMS_TP_CLIENT_MQ_TCPIP which is JAVA code.

  7. #7
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,840

    Default

    I think rhart had the right idea. Perhaps you need to configure the connectionFactory for JMS rather than MQ message types.

  8. #8
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,840

    Default

    The one difference I see is the standalone application is providing properties:
    MQEnvironment.properties.put(MQC.TRANSPORT_PROPERT Y, MQC.TRANSPORT_MQSERIES);

    Can you make sure that you are doing an apples-to-apples comparison? Spring Integration builds directly on top of Spring's JMS support, and Spring's JMS support simply builds on the JMS API. There is nothing being added in that functionality that would cause any header information to be added to the underlying JMS message (which is what this looks like). That is most likely a configuration issue.

  9. #9

    Default

    rhart is right.

    It is problem of the receiver of the MQ message which is configured as listening to an MQ message rather than a JMS message.

    I am now using a Service Activator instead of JMS Outbound channel adapter to send messages to the IBM MQ queue where I am using MQ messages instead of JMS Messages and that is working fine.

    Let me know if there is any other way as I cannot make the receiver to change to JMS as it is an existing legacy system I am talking to and out of my scope.

    Thanks for all the help.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •