Apache camel Apache Camel OneExceptionOccurred组件未按照重新交付延迟重新交付
我有一个Apache Camel route,它调用restlet组件并使用异常处理程序中的重新交付机制,异常处理程序在每次更新数据库记录失败时都会执行一些处理,但如果我提供2000的重新交付延迟,则需要24秒来重试之前的每次尝试。下面是一段代码。让我知道为什么延误比预期的要多Apache camel Apache Camel OneExceptionOccurred组件未按照重新交付延迟重新交付,apache-camel,Apache Camel,我有一个Apache Camel route,它调用restlet组件并使用异常处理程序中的重新交付机制,异常处理程序在每次更新数据库记录失败时都会执行一些处理,但如果我提供2000的重新交付延迟,则需要24秒来重试之前的每次尝试。下面是一段代码。让我知道为什么延误比预期的要多 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans"
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:cxf="http://camel.apache.org/schema/cxf"
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 http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd">
<!-- CXF Rest Endpoint Declaration -->
<cxf:rsServer address="http://localhost:9092/rest/corp"
id="FetchCDFRestRequest" serviceClass="com.tcl.Service.Service" />
<bean class="com.tcl.ExceptionOccurredRefProcessor" id="exProc" />
<bean class="org.apache.camel.builder.DeadLetterChannelBuilder"
id="DLCErrorHandler">
<property name="deadLetterUri"
value="activemq:queue:DMS.FAILURES.DLQ" />
<property name="redeliveryPolicy" ref="redeliveryPolicy" />
</bean>
<bean class="org.apache.camel.processor.RedeliveryPolicy"
id="redeliveryPolicy">
<property name="maximumRedeliveries"
value="3" />
<property name="maximumRedeliveryDelay" value="2000" />
<property name="retryAttemptedLogLevel" value="WARN" />
</bean>
<camelContext id="Corp"
xmlns="http://camel.apache.org/schema/spring">
<errorHandler id="eh" onExceptionOccurredRef="exProc">
<redeliveryPolicy id="redeliveryPolicy" />
</errorHandler>
<route errorHandlerRef="DLCErrorHandler"
id="MainRouteOppIDFolder" streamCache="true">
<from id="_CreateOppIDFolder"
uri="restlet:http://localhost:9092/rest/corp/createOppIDFolder?restletMethod=POST" />
----------
<to uri="restlet:http://localhost:9902/CreateOppIDFolder?restletMethod=POST" />
------------
<onException id="_onException1"
onExceptionOccurredRef="exProc"
redeliveryPolicyRef="redeliveryPolicy" useOriginalMessage="true">
<exception>java.lang.Exception</exception>
<handled>
<simple>true</simple>
</handled>
<log id="_log3" loggingLevel="INFO"
message="Handled ex >>>>> ${exception.message} " />
</onException>
</route>
</camelContext>
</beans>
----------
------------
java.lang.Exception
真的
下面是一些日志
14:47:52.701[Restlet-1879974483]警告o.a.c.processor.DeadLetterChannel-传递失败(Exchange上的MessageId:ID-DESKTOP-P2DBOO5-1580115333236-0-19 ID-DESKTOP-P2DBOO5-1580115333236-0-20)。交付时尝试:0捕获:org.apache.camel.component.restlet.restleOperationException:restlet操作调用失败,状态代码:500/n responseBody:org.apache.cxf.interceptor.Fault:无法发送消息
14:48:15.044[驼峰(MyCamel)线程#15-ErrorHandlerRedeliveryTask]警告o.a.c.processor.DeadletChannel-传递失败(MessageId:ID-DESKTOP-P2DBOO5-1580115331236-0-19在Exchange上ID:ID-DESKTOP-P2DBOO5-1580115331236-0-20)。交付时尝试:1捕获:org.apache.camel.component.restlet.restleOperationException:restlet操作调用失败,状态代码:500/n responseBody:org.apache.cxf.interceptor.Fault:无法发送消息
14:48:37.252[驼峰(MyCamel)线程#17-ErrorHandlerRedeliveryTask]警告o.a.c.processor.DeadletChannel-传递失败(MessageId:ID-DESKTOP-P2DBOO5-1580115331236-0-19在Exchange上ID:ID-DESKTOP-P2DBOO5-1580115331236-0-20)。交付时尝试:2捕获:org.apache.camel.component.restlet.restleOperationException:restlet操作调用失败,状态代码:500/n responseBody:org.apache.cxf.interceptor.Fault:无法发送消息
有什么建议吗?您确定需要24秒才能开始重试吗 重试失败(重试结束)是否需要24秒左右的时间 所有三条日志语句都报告来自目标端点的错误500。重试是否可能在2秒后开始,进行HTTP调用,但需要另外20秒,直到端点回答错误500
00:00 error occurs
00:02 Camel triggers retry after 2 seconds
00:02 HTTP call to http://localhost:9902...
00:xx Waiting for reponse from http://localhost:9902
00:2x Log output after 20-something seconds that retry is failed
是的,如果我提供2秒作为重新交付延迟,那么开始下一次重试大约需要24秒。不确定重试失败时需要24秒的时间。我不确定这一点,认为默认情况下驼峰需要22秒,如果我们提供0秒的重新交付延迟,如果我们提供2秒的延迟,它会增加默认延迟并重试下一次重新交付。我更新了我的答案,因为我想你没有理解我的观点。我想说的是,Camel会在2秒后正确触发重试,但是您的日志输出是重试的最终结果,而不是起点。啊,好的,明白了。如何获取下一个重新交付时间戳,camel中是否有相关属性?我不知道,但您可以将HTTP端点更改为不存在的内容。这应该会给出非常快速的响应。如果重试日志显示得更快(大约2秒后),我的猜测是正确的。