spring-retry
spring-retry copied to clipboard
Can't chose correct @Recover method
In case of multiple @Recover
method, apparently only one is considered, others are ignored.
Example:
@CircuitBreaker(openTimeout=1000, resetTimeout=2000, maxAttempts=2)
public Response submit(Object o) {
... retry logic with retryTemplate
}
@CircuitBreaker(openTimeout=1000, resetTimeout=2000, maxAttempts=2)
public Response query(String id) {
... retry logic with retryTemplate
}
@Recover
public Response fallbackForSubmit(Throwable e, Object o) {....}
@Recover
public Response fallbackForQuery(Throwable e, String id) (....}
In my case fallbackForQuery is not considered as recovery method. If I comment out fallbackForSubmit recover method - than it works.
I've seen there were some changes introduced to allow to add @Retry(recoverName="recover1")
in https://github.com/spring-projects/spring-retry/issues/85 , but it is not exactly my scenario since I'm not using @Retry
annotation but rather retryTemplate.
Could you advise how should I proceed with my problem?
Did you try @Retryable(recover=...)
(note the spelling of both annotation name and attribute)? Or is it just that you need the @CircuitBreaker
to alias that attribute before it will work? Your comment about "using retryTemplate" didn't make sense to me.
@dsyer when will this recover parameter be available in Branch 1.2.X ?
currently I'm working with 1.2.5.RELEASE which doesn't contain this yet.
It's in 1.3 I think. It looks like maybe we need an alias?
@dsyer Sorry, I completely forgot about this one. I'll try to remember from memory what was scenario (please allow some latitude - it was 2 years ago) In one of my services I had to reach out to two external calls to different clients (urls) which could be unreliable, so decision was made to annotate both of them with @CircuitBreaker. Two different @CircuitBreaker weren't the problem, but eventually I needed two different @Recover for each of them - and this couldn't be distinguished which @Recover belongs to which @CircuitBreaker. So yes, some alias or name of @CircuitBreaker with corresponding alias or name of @Recover should solve the problem.
Once again - apologies for late reply.