Reputation: 11
I have Apache Camel route which invokes restlet component and used redelivery mechanism from the exception handler which performs some processing on every failure to update my database record but if I provide the redelivery delay of 2000, it is taking 24 seconds to retry the every preceding attempt. Below is the piece of code. Let me know why it is taking more delay than expected.
<?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>
Below are some of the logs
14:47:52.701 [Restlet-1879974483] WARN o.a.c.processor.DeadLetterChannel - Failed delivery for (MessageId: ID-DESKTOP-P2DBOO5-1580115331236-0-19 on ExchangeId: ID-DESKTOP-P2DBOO5-1580115331236-0-20). On delivery attempt: 0 caught: org.apache.camel.component.restlet.RestletOperationException: Restlet operation failed invoking http://localhost:9902/CreateOppIDFolder with statusCode: 500 /n responseBody:org.apache.cxf.interceptor.Fault: Could not send Message.
14:48:15.044 [Camel (MyCamel) thread #15 - ErrorHandlerRedeliveryTask] WARN o.a.c.processor.DeadLetterChannel - Failed delivery for (MessageId: ID-DESKTOP-P2DBOO5-1580115331236-0-19 on ExchangeId: ID-DESKTOP-P2DBOO5-1580115331236-0-20). On delivery attempt: 1 caught: org.apache.camel.component.restlet.RestletOperationException: Restlet operation failed invoking http://localhost:9902/CreateOppIDFolder with statusCode: 500 /n responseBody:org.apache.cxf.interceptor.Fault: Could not send Message.
14:48:37.252 [Camel (MyCamel) thread #17 - ErrorHandlerRedeliveryTask] WARN o.a.c.processor.DeadLetterChannel - Failed delivery for (MessageId: ID-DESKTOP-P2DBOO5-1580115331236-0-19 on ExchangeId: ID-DESKTOP-P2DBOO5-1580115331236-0-20). On delivery attempt: 2 caught: org.apache.camel.component.restlet.RestletOperationException: Restlet operation failed invoking http://localhost:9902/CreateOppIDFolder with statusCode: 500 /n responseBody:org.apache.cxf.interceptor.Fault: Could not send Message.
Any suggestions please?
Upvotes: 0
Views: 581
Reputation: 7005
Are you sure it is taking 24 seconds to (begin the) retry?
Couldn't it take around 24 seconds until the retry fails (end of retry)?
All three log statements are reporting an error 500 from the target endpoint. Is it possible that the retry starts after 2 seconds, makes the HTTP call, but it takes another 20 seconds until the endpoint answers with an error 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
Upvotes: 0