Skip to content

Non retryable states and exceptions

Edvard Fonsell edited this page Mar 27, 2020 · 1 revision

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:

  1. Add @NonRetryable annotation to your exception that you don't want to retry
  2. 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.