Interface RecoverableWorkflowExceptionPolicy

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface RecoverableWorkflowExceptionPolicy
Classifies an exception that escaped a workflow body as recoverable or not.

A recoverable exception describes a condition a later run can succeed on: the engine pauses the workflow, keeps the instance non-terminal and re-drives it on the next start of the processing node or claim of its segment. Any other exception is treated as a defect in the body and fails the workflow durably, so the failure is visible and final.

DEFAULT walks the cause chain and treats these as recoverable:

The policy applies to all workflows when registered as a component, and to a single workflow when set through WorkflowCustomization.recoverableExceptionPolicy(RecoverableWorkflowExceptionPolicy). Without either, DEFAULT applies.

Example usage:


 configurer.componentRegistry(registry -> registry.registerComponent(
         RecoverableWorkflowExceptionPolicy.class,
         config -> RecoverableWorkflowExceptionPolicy.DEFAULT.or(e -> e instanceof BackendUnavailableException)
 ));
 
Since:
5.4.0
Author:
Stefan Dragisic
  • Field Details

  • Method Details

    • isRecoverable

      boolean isRecoverable(Throwable failure)
      Decides whether the given exception, which escaped the workflow body, is recoverable.
      Parameters:
      failure - the exception that escaped the workflow body
      Returns:
      true to pause the workflow for a later run, false to fail it
    • or

      Combines this policy with another one, treating an exception as recoverable when either policy does.
      Parameters:
      other - the policy to combine with
      Returns:
      a policy that accepts what this policy or the other policy accepts