RetryableExecutorException
If you are having an exception while processing the executor due to a connection issue or that kind of re-invokable error (The exceptions that can be occurred temporarily), you can throw a RetryableExecutorException
.
Then the StackSaga engine will temporarily pause the execution, and the transaction does expose to the next scheduler.
Because, the engine knows that even though the executor has an exception at this moment, the execution can be retried and run again successfully due to the retractable error.
IF you were unable to catch the exception properly, the execution might throw RuntimeException
s.
That kind of unhandled exception will be caught as non-retryable exception by the StackSaga engine.
IF the exception is a non-retryable error, you can throw it by warping with NonRetryableExecutorException
.
Retryable Executor Exceptions are allowed for the following executors.
Executor | DoProcess() Method | doRevert() Method |
---|---|---|
Query Executor |
✔ |
✔ |
Command Executor |
✔ |
✔ |
Revert Before Executor |
✔ |
|
Revert After Executor |
✔ |
It is very important to identify whether the exception is a retryable exception or not.
If you don’t identify the exceptions that are thrown when the execution is executed every time that an exception is thrown, the transaction will be stopped to forward.
Therefore, it is necessary to capture and identify all the exceptions that are thrown inside the doProcess() method.
|
@SagaExecutor(
executeFor = "user-service",
liveCheck = true,
value = "CheckUserExecutor"
)
@AllArgsConstructor
public class CheckUserExecutor implements QueryExecutor<PlaceOrderAggregator> {
private final UserService userService;
@Override
public ProcessStepManager<PlaceOrderAggregator> doProcess(
ProcessStack processStack,
PlaceOrderAggregator aggregator,
ProcessStepManagerUtil<PlaceOrderAggregator> stepManagerUtil
) throws RetryableExecutorException, NonRetryableExecutorException {
try {
ResponseEntity<UserDetailDto> userDetail = this.userService.getUserDetail(aggregator.getUsername());
...
} catch (FeignException.ServiceUnavailable unavailableException) {
throw RetryableExecutorException.buildWith(unavailableException).build();
}
}
}