I have a table update that causes a deadlock and am trying to get the Spring Retry to retry when the method gets the a locking exception of some kind. I've tried taking out the maxAttempts, value and backoff but it doesn't ever seem to catch any of the exceptions. Am I missing something? Do I need to declare a bean in the Application file? Any help would be much appreciated!
Application.Java
@SpringBootApplication
@EnableRetry
public class Application extends SpringBootServletInitializer {
DetailService
@Service
public class DetailService {
@Retryable(maxAttempts = 5, value = { LockAcquisitionException.class, ConcurrencyFailureException.class }, backoff = @Backoff(delay = 500, multiplier = 2) )
public void delete(final String detailCode) {
try {
this.delete(this.dao.findByDetailCode(detailCode));
} catch (LockAcquisitionException | ConcurrencyFailureException e) {
LOG.warn("Locking error! Going to retry", e.getMessage());
throw e;
}
}
public void delete(Details detail) {
this.dao.delete(detail);
}
@Retryable(maxAttempts = 5, value = { LockAcquisitionException.class, ConcurrencyFailureException.class }, backoff = @Backoff(delay = 500, multiplier = 2) )
public void delete(final Integer id) {
if (id != null) {
try {
this.delete(this.dao.findOne(id));
} catch (LockAcquisitionException | ConcurrencyFailureException e) {
LOG.warn("Locking error! Going to retry", e.getMessage());
throw e;
}
}
}
EDIT
Rewrote my DetailService above to give more detail and add missing methods