Member-only story
Try again with Spring Retry
6 min readSep 1, 2024
There are times when business transactions fail for unknown reasons. Some potential circumstances are:
- temporary service unavailability
- huge traffic payload causing connection timeouts
- deadlocks
Enterprise applications using the Java Spring Framework can easily recover from situations, making those transparent to the end user, by retrying actions using the Spring Retry library.
1. Cases when not using Spring Retry
There are, however, situations when retrying an action with Spring Retry is not the best approach, such as
Business case is stateful
- There could be batch processing where each chunk is saving data in several small own steps. If, for some reason, any random write step fails, chunk retry is not applicable (data left in inconsistent state)
Hiding the root cause
- Basically, it means not solving the main issue itself but trying to retry the transaction, hoping the same issue does not exist anymore.
- It may sometimes help; for example, due to high incoming traffic peak, retrying the transaction would help but the real problem might be related to the system not scaling properly.