简体   繁体   中英

ServiceActivator use only one advice instead of 2 advices fro retrying and error filtering

Do I really need to define 2 advices over ServiceActivator ( RequestHandlerRetryAdvice ) if I need to use RetryTemplate (with AlwaysRetryPolicy ) and ExpressionEvaluatingRequestHandlerAdvice where I filter the error that I don't want to retry on?

@Bean
@ServiceActivator(inputChannel = "outboundChannel", adviceChain = {"retry", "filter"})
public MessageHandler handler() { 
    JdbcMessageHandler ...
}

This works fine, but why can't I do it within one place only?

Or I should override canRetry method of AlwaysRetryPolicy and do this form there?
I tired that (retuned false) but it caused some circular loop.

I think I said you before over here: RetryTemplate with ServiceActivator and JdbcMessageHandler

See different RetryPolicy strategy implementations

I think a BinaryExceptionClassifierRetryPolicy should meet your requirements:

 * A policy, that is based on {@link BinaryExceptionClassifier}. Usually, binary
 * classification is enough for retry purposes. If you need more flexible classification,
 * use {@link ExceptionClassifierRetryPolicy}.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM