From 06c6817bee4c23f21c11a3a8b0d54a5cebccf03b Mon Sep 17 00:00:00 2001 From: "gu.martinm@gmail.com" Date: Tue, 14 Oct 2014 19:21:46 +0200 Subject: [PATCH] Spring DeadLocks retries --- .../java/de/example/sql/deadlocks/aspect/DeadlockRetryAspect.java | 5 ++++- SpringJava/DeadLocksSQL/src/main/resources/spring-config.xml | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/SpringJava/DeadLocksSQL/src/main/java/de/example/sql/deadlocks/aspect/DeadlockRetryAspect.java b/SpringJava/DeadLocksSQL/src/main/java/de/example/sql/deadlocks/aspect/DeadlockRetryAspect.java index 6d1006f..1aa1915 100644 --- a/SpringJava/DeadLocksSQL/src/main/java/de/example/sql/deadlocks/aspect/DeadlockRetryAspect.java +++ b/SpringJava/DeadLocksSQL/src/main/java/de/example/sql/deadlocks/aspect/DeadlockRetryAspect.java @@ -72,7 +72,10 @@ public class DeadlockRetryAspect implements Ordered { } } while (count < maxTries); - throw new RuntimeException("DeadlockRetry failed, deadlock in all retry attempts.", lastException); + // Throwing exception because it matched or it contains (exception chaining) + // some of the exceptions from the list in the spring-config.xml file. + // The exception being thrown will depend on the API that you are using. + throw lastException; } @Override diff --git a/SpringJava/DeadLocksSQL/src/main/resources/spring-config.xml b/SpringJava/DeadLocksSQL/src/main/resources/spring-config.xml index f8c6235..ff5e273 100644 --- a/SpringJava/DeadLocksSQL/src/main/resources/spring-config.xml +++ b/SpringJava/DeadLocksSQL/src/main/resources/spring-config.xml @@ -69,8 +69,13 @@ + com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException + org.springframework.dao.DeadlockLoserDataAccessException -- 2.1.4