Is Spring Retry guaranteed to work with Spring\'s @Transactional annotation?
Specifically, I\'m trying to use @Retryable for optimistic loc
In case you are using Spring Boot and you want to use @Retryable, this is what you need to do:
org.springframework.retry
spring-retry
@EnableRetry // <-- Add This
@SpringBootApplication
public class SomeApplication {
public static void main(String[] args) {
SpringApplication.run(SomeApplication.class, args);
}
}
@Retryable:@Retryable(value = CannotAcquireLockException.class,
backoff = @Backoff(delay = 100, maxDelay = 300))
@Transactional(isolation = Isolation.SERIALIZABLE)
public boolean someMethod(String someArg, long otherArg) {
...
}
You can annotate the same method with both @Retryable and @Transactional and it will work as expected.