Using Circuit Breaker with camel -ThrottlingExcept

2019-06-04 12:54发布

问题:

There is a route which is consuming messages from a jms queue and after doing some processing sending a request to unreliable web service(Which can be down at times). So in case of service is down then i need to stop consuming from queue for some time. I tried to use ThrottlingExceptionRoutePolicy . It will stop route as per configuration but issue is for the current message which gets the error as message is getting moved to dead letter queue. I've gone through the code of ThrottlingExceptionRoutePolicy as per code this will be called after all error handling is done for route. So i need to modify default error handling of camel to avoid putting message to DLQ for some specific cases. I tried to configure various error handlers provided by camel but in all cases camel is putting messages to DLQ. Is there some configuration or i need to write custom error handler to achieve the same.

<camel:route id="someroute" routePolicyRef="throttlingExceptionRoutePolicy"
     errorHandlerRef="myTransactionErrorHandlerErrorHandler">
    <camel:from uri="activemq:inputQueue" />
    <camel:transacted />
    <camel:bean ref="afterQueueProcessor" />
    <camel:setHeader headerName="CamelHttpMethod">
        <camel:constant>POST</camel:constant>
    </camel:setHeader>
    <camel:setHeader headerName="Content-Type">
        <camel:constant>application/xyz</camel:constant>
    </camel:setHeader>

    <camel:to
        uri="http://localhost:8080/some-ws/newOrder?orderId=dd&amp;productName=bb&amp;quantity=1" />
</camel:route>

This questions is related to async communication