We are using Spring Integration for our chains of actions. We want to use one transaction for one flow (all beans should use the same transaction). That's why we are using "REQUIRED" flag for transactions which will allow to use existing transaction. But in some beans we want to use retryable feature. So if some exception occurs in a method, we want to wait a little bit and then try to execute a logic again. As far as I understand, Spring will really use initial transaction but it got marked as rollback-only. Then the other beans in the flow execute their logic successfully.
@Transactional
@Retryable(
maxAttempts = 10,
backoff = @Backoff(delay = 3000),
value = PessimisticLockException.class
)
public String someMethod(String someData) {
The problem is that in the end, I can see in the logs exception
Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Transaction marked as rollbackOnly
So is it possible to force Spring not to mark the transaction as rollback-only? Or probably we misunderstood something.