Skip to content

Workflow definition settings

Edvard Fonsell edited this page Mar 5, 2020 · 4 revisions

Workflow definitions extending WorkflowDefinition may choose to use default or customized workflow settings. The following settings are supported:

Setting Default value Description
minErrorTransitionDelay 1 minute Minimum delay on execution retry after an error. This defines the minimum delay when calculating binary backoff delay. Unit is milliseconds.
maxErrorTransitionDelay 1 day Maximum delay on execution retry after an error. This defines the maximum delay when calculating binary backoff delay. Unit is milliseconds.
shortTransitionDelay 30 seconds Length of forced delay to break execution of a step that is considered to be busy looping. Unit is milliseconds.
immediateTransitionDelay 0 Immediate transition delay.
maxRetries 17 Maximum retry attempts. When this is exceeded, workflow instance is moved to a failure state.
maxSubsequentStateExecutions 100 Maximum number of subsequent state executions before forcing a short transition delay.
maxSubsequentStateExecutionsPerState undefined Same as above, but this can be used to override the value for given states.
historyDeletableAfter null Default period after which old workflow state variables and actions can be deleted. The latest state variable values are always preserved. By default for normal workflows the history is not deleted. By default for any workflow extending CronWorkflow the period is 45 days.
deleteHistoryCondition onAverageEveryNthExecution(100) A boolean supplier that defines whether or not to delete the workflow instance history after processing a state method. By default, returns true once per 100 invocations on average.
defaultPriority 0 Default priority for new workflow instances. Used if the priority is not set per instance. Instances with higher priority value are executed before instances with lower priority value. Priority can also be negative.

To use the default settings, your workflow definition constructor should call the super constructor like this:

public MyWorkflow() {
  super("myWorkflow", State.start, State.error);
}

To use custom settings, your workflow definition constructor can call the super constructor like this:

public MyWorkflow() {
  super("myWorkflow", State.start, State.error, new WorkflowSettings.Builder()
    .setMinErrorTransitionDelay(300)
    .setMaxErrorTransitionDelay(1000)
    .setShortTransitionDelay(200)
    .setImmediateTransitionDelay(100)
    .setMaxRetries(10)
    .setMaxSubsequentStateExecutions(10)
    .setMaxSubsequentStateExecutions(State.start, 20)
    .setMaxSubsequentStateExecutions(State.error, 5)
    .setHistoryDeletableAfter(Period.days(30))
    .setDeleteHistoryCondition(WorkflowSettings.Builder.oncePerDay())
    .setMaxSubsequentStateExecutions(State.error, 5)
    .setDefaultPriority((short) 10)
    .build());
}