【问题标题】:Time out error in processing route处理路径超时错误
【发布时间】:2017-04-07 14:48:36
【问题描述】:

我正在从队列向休息 api 发送请求,并得到响应。如果响应不是 201,那么我必须再次将相同的请求再次推送到队列。但是当我将它推送到队列时,我收到了一个错误,如下所示:

org.apache.camel.ExchangeTimedOutException:未收到 OUT 消息:20000 毫秒到期回复消息,相关 ID:Camel-ID-01HW828056-64538-1479908182896-32-4 未在目的地收到:临时队列:/ /ID:01HW828056-64546-1479908191870-15:3:1。

这是我的 blueprint.xml

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
    xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
    xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf"
    xmlns:cxf-core="http://cxf.apache.org/blueprint/core"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="              http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd              http://camel.apache.org/schema/blueprint/cxf http://camel.apache.org/schema/blueprint/cxf/camel-cxf.xsd              http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">

  <camelContext xmlns="http://camel.apache.org/schema/blueprint" trace="false">
    <route id="fromqueuecontext">
         <from uri="activemq:queue:request?asyncConsumer=true"/>
          <unmarshal>
            <jaxb partClass="partclassname" prettyPrint="true" contextPath="contextname"/>
        </unmarshal>  
        <setProperty propertyName="capturequeuebean">
            <simple>${body}</simple>
        </setProperty>
        <log message="${property.capturequeuebean.orderNum}"/>
        <log message="${property.capturequeuebean.transactionNumber}"></log>
                     <removeHeaders pattern="*" />
                    <setHeader headerName="CamelHttpMethod" id="_setHeader1">
                        <constant>PUT</constant>
                    </setHeader>
                    <setHeader headerName="Content-Type" id="_setHeader2">
                        <constant>application/json</constant>
                    </setHeader>

                    <setBody>
                        <simple>${body.captureRequest}</simple>
                    </setBody>

                    <marshal>
                        <json library="Jackson"/>
                    </marshal>
                    <log message="sending body ${body}"/>
                    <convertBodyTo type="java.io.InputStream" id="_convertBodyTo1" />          
                    <recipientList>
                        <simple><!--url to be sent --></simple>
                    </recipientList>
                    <log message="${header.CamelHttpResponseCode}" />
                    <choice>
                        <when>
                            <simple>${header.CamelHttpResponseCode} != 201 and ${property.capturequeuebean.count} &gt; 0</simple>

                             <log message="inside 1st when"></log>
                            <setBody>
                                <simple>${property.capturequeuebean}</simple>
                            </setBody>
                             <bean ref="CaptureBusinessImpl" method="changecount"></bean>
                             <log message="${body.count}"></log> 
                            <to uri="activemq:queue:request" /> 
                        </when>
                        <otherwise>
                            <choice>
                                <when>
                                    <simple>${header.CamelHttpResponseCode} == 201 </simple>
                                    <log message="Sucess"></log>
                                </when>
                                <otherwise>
                                    <choice>
                                        <when>
                                            <simple>${property.capturequeuebean.count} == 0</simple>
                                            <log message="exception"></log>
                                        </when>
                                    </choice>
                                </otherwise>
                            </choice>
                        </otherwise>
                    </choice>
    </route>
  </camelContext>

</blueprint>

【问题讨论】:

  • 如果是关于重试REST调用,为什么不使用骆驼错误处理程序的redelivery policy
  • 你能告诉我在这种情况下怎么做吗???
  • 你为什么不尝试一下,如果你的尝试失败了再回来提问?

标签: apache-camel activemq jbossfuse


【解决方案1】:

在某处指定了 JMSReplyTo 标头,并且 activemq 组件正在临时队列上创建消费者以等待响应。响应没有在 20,000 毫秒内返回,因此 activemq 组件正在放弃并抛出错误。

可以通过向 activemq 端点添加以下选项来禁用自动回复处理:

?disableReplyTo=true&amp;preserveMessageQos=true

在此处查看注释:Camel JMS Component

【讨论】:

  • 实际上这帮助我让这个功能发挥作用。值得点赞。
猜你喜欢
  • 1970-01-01
  • 2015-05-07
  • 2013-05-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-02-01
  • 2020-05-26
相关资源
最近更新 更多