From 2e51f32687a10c304b15e06f83d7e06d517b43b1 Mon Sep 17 00:00:00 2001 From: "gu.martinm@gmail.com" Date: Tue, 14 Oct 2014 10:18:35 +0200 Subject: [PATCH] Spring DeadLocks retries --- .../de/example/sql/deadlocks/aspect/DeadlockRetryAspect.java | 6 ++++++ SpringJava/DeadLocksSQL/src/main/resources/spring-config.xml | 12 ++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) 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 211a061..6d1006f 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 @@ -10,6 +10,7 @@ import org.aspectj.lang.reflect.MethodSignature; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.core.Ordered; +import org.springframework.core.annotation.Order; import de.example.sql.deadlocks.annotation.DeadlockRetry; @@ -18,8 +19,13 @@ import de.example.sql.deadlocks.annotation.DeadlockRetry; * */ @Aspect +@Order(99) public class DeadlockRetryAspect implements Ordered { private static final Logger logger = LoggerFactory.getLogger(DeadlockRetryAspect.class); + /** + * Whatever you want as long as it has a higher value than the one used by + * annotation-driven transaction-manager (it uses by default Ordered.LOWEST_PRECEDENCE) + */ private static final int ORDER = 99; private Collection> retryableExceptionClasses; diff --git a/SpringJava/DeadLocksSQL/src/main/resources/spring-config.xml b/SpringJava/DeadLocksSQL/src/main/resources/spring-config.xml index 637353b..f8c6235 100644 --- a/SpringJava/DeadLocksSQL/src/main/resources/spring-config.xml +++ b/SpringJava/DeadLocksSQL/src/main/resources/spring-config.xml @@ -79,8 +79,16 @@ - - + +