4

If I have a method that has a Spring retryable for a certain exception, and also has a Transactional(Requires_new), every time the retry is done, will it create a new transaction or use the existing one?

ie

@Retryable(maxAttempts = 5, backoff = @Backoff(delay = 250), include = {ActivitiOptimisticLockingException.class})
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void setVariable(String processId, String variableName, String variableValue){
    engine.getRuntimeService().setVariable(processId, variableName, variableValue);
}

What will actually happen here?

Crackers91
  • 149
  • 3
  • 16

1 Answers1

3

will be created new transaction each time. it the same as get service from spring context and call method N times. every call creates new transaction (use propagation that you added into service or method). Call your transactioanl servics method call it's call a proxy, retry calls that proxy also. Also your transaction might have timeout,retry try call in new timeout duration ,not N try times in one timeout

xyz
  • 5,228
  • 2
  • 26
  • 35