Class StepDecision
Every Step.execute(Context, I) call returns one decision. A decision may schedule next Steps,
complete or fail the Flow, leave the execution idle, or complete only after specified Channels
become empty. Output values are serialized by the worker and are available to waiting clients.
if (order.cancelled) {
return StepDecision.forceComplete("cancelled");
}
return StepDecision.goTo(ChargeOrder.class, order)
.withCancelingSiblingSteps(ReserveInventory.class, QuoteShipping.class);
-
Method Summary
Modifier and TypeMethodDescriptionstatic StepDecisiondeadEnd()Leaves this execution with no next Step and without completing the Flow.static StepDecisionImmediately completes the Flow without an output value.static StepDecisionforceComplete(Object output) Immediately completes the Flow with an output value.static StepDecisionforceCompleteIfChannelsEmpty(Object output, StepMovement<?> fallback, Object... channels) Completes when all selected Channels are empty, otherwise schedules a fallback movement.static StepDecisionFails the Flow with an application-provided reason.static <I> StepDecisionSchedules one typed next Step.static StepDecisiongoToMany(StepMovement<?>... movements) Schedules zero or more next-Step movements together.static StepDecisionRequests successful Flow completion after all execution branches stop, without an output.static StepDecisiongracefulComplete(Object output) Requests successful Flow completion after all execution branches stop and records an output.withCancelingSiblingSteps(Class<? extends Step<?>>... stepClasses) Cancels selected sibling Step executions that share the current execution's scheduling source.withCancelingSteps(Class<? extends Step<?>>... stepClasses) Cancels queued or active executions of the selected Step types in the current Flow.
-
Method Details
-
goTo
Schedules one typed next Step.- Type Parameters:
I- the target Step input type- Parameters:
stepClass- the target Step classinput- the typed target input- Returns:
- a next-Step decision
-
goToMany
Schedules zero or more next-Step movements together.- Parameters:
movements- the movements to schedule- Returns:
- a multi-movement decision
-
gracefulComplete
Requests successful Flow completion after all execution branches stop, without an output.This decision stops the current branch without scheduling another Step, but it does not interrupt Steps that are already running in parallel. Those branches may continue and schedule their next Steps. Dex changes the Flow status to
FlowStatus.COMPLETEDonly after no active or queued Steps remain. UseforceComplete()to stop every branch immediately, ordeadEnd()to stop only the current branch without requesting Flow completion.- Returns:
- a graceful-completion decision
-
gracefulComplete
Requests successful Flow completion after all execution branches stop and records an output.This decision has the branch-draining behavior described by
gracefulComplete(). The output is serialized as this branch's completion output. When the Flow completes,Client.waitForFlow(String)returns every recorded Step output with its Step identity. Parallel completion order is not a business ordering contract.- Parameters:
output- the serializable output for this execution branch, ornull- Returns:
- a graceful-completion decision
-
forceComplete
Immediately completes the Flow with an output value.- Parameters:
output- the serializable Flow output, ornull- Returns:
- a force-completion decision
-
forceComplete
Immediately completes the Flow without an output value.- Returns:
- a force-completion decision
-
forceCompleteIfChannelsEmpty
public static StepDecision forceCompleteIfChannelsEmpty(Object output, StepMovement<?> fallback, Object... channels) Completes when all selected Channels are empty, otherwise schedules a fallback movement.- Parameters:
output- the serializable Flow output used when Channels are emptyfallback- the movement scheduled when at least one Channel is not emptychannels- theChannelorChannelMapdefinitions that must be empty- Returns:
- a conditional force-completion decision
-
forceFail
Fails the Flow with an application-provided reason.- Parameters:
reason- the user-visible failure reason- Returns:
- a force-failure decision
-
deadEnd
Leaves this execution with no next Step and without completing the Flow.- Returns:
- a dead-end decision
-
withCancelingSteps
Cancels queued or active executions of the selected Step types in the current Flow.Dex resolves the selection as a snapshot after the current execution succeeds. Existing executions that already finished, were canceled, or do not exist are ignored. Newly scheduled movements in this decision are not part of the snapshot. Dex interrupts a selected Java handler when cancellation reaches its Worker and continues with this decision without waiting for that handler to return.
Repeated calls take the union of their arguments. A Flow-wide selection supersedes a sibling-only selection for the same registered Step class. Each argument must be one class registered with the current Flow; a
nullor external Step class causes an invalid Step result.- Parameters:
stepClasses- registered Step classes whose queued or active executions should be canceled- Returns:
- a new decision containing the combined cancellation selection
-
withCancelingSiblingSteps
Cancels selected sibling Step executions that share the current execution's scheduling source.A sibling has the same
Context.getFromStepExecutionId()as the execution returning this decision. Dex applies the same snapshot, no-op, and handler interruption semantics aswithCancelingSteps(Class[]). Repeated calls take the union of their arguments, while a Flow-wide selection for a Step type supersedes its sibling-only selection.- Parameters:
stepClasses- registered Step classes whose matching sibling executions should be canceled- Returns:
- a new decision containing the combined sibling cancellation selection
-