1

目前我正在使用 Apache Camel。我想要做的是配置请求回复。这是我的路线:

<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>

在这些路线上,我们可以看到我有用于输入的 http 端点和 2 个 wmq 端点,1 个用于写入,1 个用于读取。

我想要的是:

  1. 接收来自http的请求,进行处理,将请求消息写入Queue.Write wmq。
  2. 请求消息写入 Queue.Write wmq 后,我想从 Queue.Read wmq 中读取响应,然后将其发送回第一个路由,并进行一些数据转换
  3. 完成所有操作后,我想将响应发送回 http 端点。

我已阅读 Apache Camel 的以下文档并尝试按照建议进行操作:

  1. http://camel.apache.org/request-reply.html
  2. http://camel.apache.org/jms.html
  3. 以及其他一些相关资源

但没有什么对我有用。

  1. InOut 交换模式不起作用,因为我使用不同的端点进行请求-回复
  2. 我尝试通过添加以下内容在我的 Queue.Read 端点上声明 JMSCorrelationID 和 JMSReplyTo:
<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>

但它也没有工作,而且,我只是不断地收到以下错误:

org.apache.camel.ExchangeTimedOutException:未收到 OUT 消息:20000 毫秒到期回复消息,相关 ID:未收到 cid。交流[消息: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] 在 org.apache.camel.component.jms.reply.ReplyManagerSupport.processReply(ReplyManagerSupport.java:133) 在 org.apache.camel.component.jms.reply.TemporaryQueueReplyHandler.onTimeout(TemporaryQueueReplyHandler.java: 61) 在 org.apache.camel.component.jms.reply.CorrelationTimeoutMap.onEviction(CorrelationTimeoutMap.java:30) 在 org.apache.camel.component.jms.reply.CorrelationTimeoutMap.onEviction(CorrelationTimeoutMap.java:30) 在 org.apache.camel.component.jms.reply.CorrelationTimeoutMap.onEviction(CorrelationTimeoutMap.java:53) .apache.camel.support.DefaultTimeoutMap.purge(DefaultTimeoutMap.java:212) 在 org.apache.camel.support.DefaultTimeoutMap.run(DefaultTimeoutMap.java:162) 在 java.util.concurrent.Executors$RunnableAdapter。在 java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown) 在 java.util.concurrent.FutureTask.runAndReset(Unknown Source) 调用(Unknown Source)源) 在 java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 在 java.lang.Thread.run(Unknown Source) 在 java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

仅供参考,我已尝试在 Mule ESB 上这样做,并通过使用以下方法成功实现它:

骡子示例

并添加

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

在我的 Queue.Read 在第二个流程之后。

但是,现在我需要在 Apache Camel 中进行。骆驼有什么办法吗?或者您对如何解决我的问题有一些想法(不更改 wmq 端点)。谢谢你的帮助。

4

1 回答 1

1

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.

于 2014-06-16T17:25:13.783 回答