Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the interaction between the @Transactional and @Retryable annotations in spring?

According to Does annotations order matter? the order shouldn't matter, however for these two it seems that the order does matter.

If the transaction occurs within the retry, then the transaction could roll back, throw an exception, then spring will retry it. However if the retry occurs within the transaction, there won't be a rollback between each retry as the retry will catch the exception and go again.

There could be also situations like the database details changing between retries.

like image 888
Bryan Tan Avatar asked Sep 02 '25 02:09

Bryan Tan


1 Answers

There was a recent change to the order; see https://github.com/spring-projects/spring-retry/pull/335 and https://github.com/spring-projects/spring-retry/pull/333#pullrequestreview-1330977780

It will be available in 2.0.1 (currently in 2.0.1-SNAPSHOT).

like image 94
Gary Russell Avatar answered Sep 07 '25 08:09

Gary Russell