}
} 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
<bean id="deadlockRetryAspect" class="de.example.sql.deadlocks.aspect.DeadlockRetryAspect">
<property name="retryableExceptionClasses">
+ <!--
+ You have to add here the exceptions for your API. In this case it is
+ spring-tx and JDBC.
+ -->
<list value-type="java.lang.String">
<value>com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException</value>
+ <value>org.springframework.dao.DeadlockLoserDataAccessException</value>
</list>
</property>
</bean>