0

I am developing a Spring boot application. From my application we are calling an external RestService and want to retry if RestCall fails for any reason.

I know that @Retryable within spring should take care of this. I am trying to implement something like below with parameters:

@Retryable(maxAttempts=3,value=RunTimeException.class,backoff = @Backoff(delay = 900000))

Now my problem is, there are multiple clients who will call this service. When client1 is calling this service, i want to retry when a failure occurs after 15min. When client2 is calling this service, i want to retry when a failure occurs after 1sec.

So i want to know if there is any way we can configure the delay in retryable based on client1 or client2.

Any suggestions are helpful.

ging
  • 219
  • 7
  • 20

1 Answers1

0

You can use a ThreadLocal<Long> @Bean to store the delay and then use delayExpression="@threadLocalBean.get().

However, suspending a thread for 15 minutes is a bit severe.

You would be better using a scheduler for the retries in that case.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179