Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring new transaction combined with Retryable

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?

like image 747
Crackers91 Avatar asked Oct 28 '25 15:10

Crackers91


1 Answers

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

like image 196
xyz Avatar answered Oct 31 '25 06:10

xyz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!