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:
- Receive a request from the http, process it, and write request message to Queue.Write wmq.
- 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
- 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:
- http://camel.apache.org/request-reply.html
- http://camel.apache.org/jms.html
- And some other related resources
But nothing is working for me.
- The InOut exchange pattern is not working, because I used different endpoint for the request-reply
- 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:
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.