I am using annotation based approach - @Retryable to do retry in spring boot application.
@Retryable(value = {DataAccessException.class, JpaSystemException.class}, maxAttempts = Integer.MAX_VALUE, backoff = @Backoff(delay = 30000))
What I want to do is, everytime it retries I want to access its current retry attempt.
I tried doing this using Java Reflection -
Retryable retryable = mth.getAnnotation(Retryable.class);
But using this I am not getting the current retry attempt. It just gives the details which are been added to the @Retryable attribute like value, maxAttempts, Backoff details
Any idea on this? Help is highly appreciated.
You can't access the template, unless you wire up your own interceptor and provide it to the @Retryable in the interceptor property.
You can, however access the count within the @Retryable method using
int retry = RetrySynchronizationManager.getContext().getRetryCount();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With