Camel - How to configure redeliver only for HTTP Code 500 series

947 Views Asked by At

I have configured the re delivery related properties as follows. In fact, I wanted to retry only for HTTP Code 500x series. But I see that onException() takes only exception type. How to achieve this? My application is spring boot & camel based.

errorHandler(defaultErrorHandler().maximumRedeliveries(3).redeliveryDelay(5000).logRetryAttempted(true).logExhausted(true));

onException().retryAttemptedLogLevel(LoggingLevel.WARN)

Camel 2.23 is the version I am using(As per the comment).

1

There are 1 best solutions below

1
On

Need more information, how you get resp code.
if you get response from camel route you can add condition in route:

.choice().when().simple("header.HTTP_RESPONSE_CODE >= 500").errorHandler(defaultErrorHandler().maximumRedeliveries(3).redeliveryDelay(5000).logRetryAttempted(true).logExhausted(true)).end();