1
votes

As described here: setting ReplyToQ attribute of MQMD of IBM MQ request message with Camel I managed to set ReplyToQ in MQMD of request properly in Camel Route, but I can't get the response in the same Route, with the IBM MQ Endpoint ("to") that I would like to use both for output (of request) and for input (of response), because it is matching wrong Correlation ID, like this:

The OUT message was not received within: 20000 millis due reply message with correlationID: Camel-ID-MYPC-62418-1518179436629-0-5 not received on destination: queue:///REPLYQ. Exchange[ID-MYPC-62418-1518179436629-0-4]

Namely, responding application sets CorrelationID (in MQMD) to the MessageID (from MQMD of the received request). How to make this scenario work?

I tried with useMessageIDAsCorrelationID, but this doesn't change much the result (responses are not consumed). Another try was to set MessageID of request to some fixed value (that would not be final solution), but I can't even do that. I added this:

        <setHeader headerName="JMSMessageID" id="_setHeader2">
            <constant>abcdefg</constant>
        </setHeader>
        <setHeader headerName="JMSCorrelationID" id="_setHeader3">
            <constant>abcdefg</constant>
        </setHeader>

but this only sets CorrelationID, and I still get such things:

The OUT message was not received within: 20000 millis due reply message with correlationID: abcdefg not received on destination: queue:///REPLYQ. Exchange[ID-MYPC-65151-1518190285422-0-3]

Complete route definition:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:camel="http://camel.apache.org/schema/spring"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
    <bean class="org.apache.camel.component.jms.JmsComponent" id="websphere">
        <property name="connectionFactory">
            <bean class="com.ibm.mq.jms.MQConnectionFactory">
                <property name="transportType" value="1"/>
                <property name="hostName" value="hostname"/>
                <property name="port" value="port"/>
                <property name="queueManager" value="qmgr_name"/>
                <property name="channel" value="channel_name"/>
            </bean>
        </property>
    </bean>
    <!-- Define a traditional camel context here -->
    <camelContext id="camel" useBreadcrumb="false" xmlns="http://camel.apache.org/schema/spring">
        <route id="simple-route">
            <from id="request-file" uri="file://C:/mqdocuments/?fileName=request.txt"/>
            <log id="route-log" message=">>> ${body}"/>
            <setHeader headerName="CamelJmsDestinationName" id="_setHeader1">
                <constant>queue://QM_TEST/INPUTQ?targetClient=1&amp;mdWriteEnabled=true&amp;mdReadEnabled=true</constant>
            </setHeader>
            <setHeader headerName="JMSMessageID" id="_setHeader2">
                <constant>abcdefg</constant>
            </setHeader>
            <setHeader headerName="JMSCorrelationID" id="_setHeader3">
                <constant>abcdefg</constant>
            </setHeader>
            <to id="_to1" pattern="InOut" uri="websphere:queue:SYSTEM.DEFAULT.LOCAL.QUEUE?replyTo=REPLYQ"/>
        </route>
    </camelContext>
</beans>
1
Btw, last setHeader tag properly sets CorrelationID in MQMD of request message, but that doesn't help much, since responding application doesn't use that attribute of request message.hdjur_jcv
And I would expect useMessageIDAsCorrelationID to be useful if I was to implement in Camel a responding service, that has to set CorrelationID of response to MessageID of received request, which is not the case here.hdjur_jcv
Could you add the complete route definition?thuri
Do you see actually see correct replyto properties in the MQMD header`?Souciance Eqdam Rashti
@thuri Here you are, I updated the question with the whole route definition.hdjur_jcv

1 Answers

1
votes

OK, this simple code actually works as explained here:

http://camel.apache.org/correlation-identifier.html

    <route id="simple-route">
        <from id="request-file" uri="file://C:/mqdocuments/?fileName=request464.txt"/>
        <log id="route-log-request" message="request: ${body}"/>
        <setHeader headerName="CamelJmsDestinationName" id="_setHeader1">
            <constant>queue://QM_TEST/INPUTQ?targetClient=1</constant>
        </setHeader>
        <to id="_to1" pattern="InOut" uri="websphere:queue:SYSTEM.DEFAULT.LOCAL.QUEUE?useMessageIDAsCorrelationID=true&amp;replyTo=REPLYQ"/>
        <log id="route-log-response" message="response: ${body}"/>
    </route>

It prints out neatly response body to console output. I don't know why I was under impression that it doesn't work when I first tried it. So, to summarize both questions, the catch is in using useMessageIDAsCorrelationID and replyTo parameters in uri of a queue, as well as pattern="InOut" parameter of <to> endpoint.