2
votes

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?

1
What are your tests results ?JEY

1 Answers

3
votes

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