1
votes

currently I am working with Apache Camel. What I want to do is configuring request reply. Here is my routes:

<route>
            <from uri="jetty:http://localhost:8888/uebermittleAusweisdaten"/>
            <process ref="TransformToXML"/>
            <to uri ="xslt:mobako.sender.xsl"/>
            <setHeader headerName="CamelJmsDestinationName">
                <constant>queue:///LSMH.ZKSEAP.SERVICEBUS?targetClient=1</constant>    
            </setHeader>
            <setHeader headerName="JMS_IBM_Character_Set">
                <constant>ISO8859_1</constant>    
            </setHeader>
            <setHeader headerName="JMSCorrelationID">
                <constant>cid</constant>    
            </setHeader>
            <to uri="jms:queue:Queue.Write"/>
            <marshal ref="xmljson"/>
            <!-- <process ref="ResponseToHTML"/> -->
        </route>
        <route>
            <from uri="jms:queue:Queue.Read" />
            <setBody><simple>IN: ${headers}</simple></setBody>
            <to uri="stream:out"/>
        </route>

On those reoutes, we can see that I have http endpoint used for input and 2 wmq endpoint, 1 for write and 1 for read.

What I want is:

  1. Receive a request from the http, process it, and write request message to Queue.Write wmq.
  2. After the request message has writen in the Queue.Write wmq, I would like to read the response from Queue.Read wmq, then send it back to the first route, and do some data transformation
  3. After all the proceed has been done, then I would like to send back the response to the http endpoint.

I have read following documentation from Apache Camel and tried to do as suggested:

  1. http://camel.apache.org/request-reply.html
  2. http://camel.apache.org/jms.html
  3. And some other related resources

But nothing is working for me.

  1. The InOut exchange pattern is not working, because I used different endpoint for the request-reply
  2. I tried to declare the JMSCorrelationID and JMSReplyTo on my Queue.Read endpoint by adding:
<interceptFrom uri="jms:queue:ZKSEAP.LSMH.SERVICEBUS">
          <setHeader headerName="JMSCorrelationID">
              <constant>cid</constant>    
          </setHeader>
          <setHeader headerName="JMSReplyTo">
              <constant>queue:///LSMH.ZKSEAP.SERVICEBUS?targetClient=1</constant>
          </setHeader>
      </interceptFrom>

But it also did not work, moreover, I just got following error continously:

org.apache.camel.ExchangeTimedOutException: The OUT message was not received within: 20000 millis due reply message with correlationID: cid not received. Exchange[Message: http://security.fraport.de/zks-eap/uebermittleAusweisdatenurn:uuid:ID-FRA000000085404-55438-1402901836300-0-2esbp://services.fraport.de/lsmh/mobakoesbp://services.fraport.de/lsmh/zks-eapesbp://services.fraport.de/lsmh/mobako11.2] at org.apache.camel.component.jms.reply.ReplyManagerSupport.processReply(ReplyManagerSupport.java:133) at org.apache.camel.component.jms.reply.TemporaryQueueReplyHandler.onTimeout(TemporaryQueueReplyHandler.java:61) at org.apache.camel.component.jms.reply.CorrelationTimeoutMap.onEviction(CorrelationTimeoutMap.java:53) at org.apache.camel.component.jms.reply.CorrelationTimeoutMap.onEviction(CorrelationTimeoutMap.java:30) at org.apache.camel.support.DefaultTimeoutMap.purge(DefaultTimeoutMap.java:212) at org.apache.camel.support.DefaultTimeoutMap.run(DefaultTimeoutMap.java:162) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask.runAndReset(Unknown Source) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

Just for your information, I have tried to do so on Mule ESB and successfully implement it by using:

Mule-Example

and adding

<vm:outbound-endpoint path="response"/>

after my Queue.Read on second flow.

But, for now I need to do it in Apache Camel. Is there any ways to do so in Camel? Or do you have some idea about how to solve my problem (without change the wmq endpoint). Thanks for your help.

1

1 Answers

1
votes

Because you set the JMSDestiantion hader queue:///LSMH.ZKSEAP.SERVICEBUS?targetClient=1 then Camel sends the message to the queue LSMH.ZKSEAP.SERVICEBUS so you need a listener on that queue, that processes the message, and send back the reply message defined by the standard JMSReplyTo header.

And because you did not set any special replyTo, then Camel uses a temporary queue. Not sure if IBM WebSphere support this. So you may want to set a fixed JMSReplyTo header. See more details at that Camel JMS doc as it talks about that.

The 2nd route you have is likely not in use because its reading from Queue.Read which you did not send a message to.

But read that JMS page again, and pay attention to different kinds of reply over JMS with a shared / temporary or exclusive reply queue.