-
Notifications
You must be signed in to change notification settings - Fork 39
Non retryable states and exceptions
Release 7.1.0 added support for marking exceptions and workflow states as non-retryable. If processing the state method throws an exception, nFlow engine will check if it is allowed to retry. If not, the workflow instance will go directly to a failure/error state. There are 2 ways to disable the default retry mechanism:
- Add
@NonRetryable
annotation to your exception that you don't want to retry - Override
WorkflowState.isRetryable(Throwable thrown)
The annotation check is applied to all states of all workflow definitions, unless the isRetryable
is overridden in some WorkflowState
.
If you override the isRetryable
method, you may still call WorkflowState.super.isRetryAllowed(thrown)
to check the annotation.
If you need more complex logic that includes accessing injected objects or StateExecution
interface, you should implement that logic in the state method.
For a working example, see NoRetryWorkflow
class in nflow-tests
module.