Java API Reference
The ProcessEngine API lives in compileflow-api. Deployment and Durable execution have separate APIs in
compileflow-deploy-api and compileflow-durable-api, covered below. Engine implementation classes, parser models,
Spring internals, and Server DTOs are not public Java API unless explicitly documented as such.
The general extension framework and com.alibaba.compileflow.common.text.UnicodeText live in compileflow-common,
which is brought in by compileflow-api. See the Extension Guide for declaration and invocation.
Find the API for your task:
| Task | Sections |
|---|---|
| Create and invoke a regular engine | Lifecycle, identity, execution, results |
| Pass routing inputs or choose a trigger entry | Request metadata, triggered entries |
| Check, warm, load, or extend an engine | Local administration, mapping, extensions |
| Publish versions or work with persistent Runs | Deployment, Durable |
| Distinguish failure, missing records, and exceptions | Failure boundary |
1. Engine Lifecycle
Section titled “1. Engine Lifecycle”Reuse one long-lived ProcessEngine for each set of configuration and resources. Create another engine when those need to be independent.
The engine discovers installed TBBPM/BPMN format providers and manages its executors, runtime cache, and generated-class loaders.
| Factory method | Purpose |
|---|---|
ProcessEngineFactory.create() |
Create an engine with default settings |
ProcessEngineFactory.create(config) |
Create an engine with the supplied settings |
ProcessEngineFactory.create(config, components) |
Also supply a ProcessComponentResolver so type="bean" actions can look up existing objects by name and type, without requiring Spring |
A class action can use any of the three factories. It constructs a new instance through the declared class’s public no-argument constructor for each invocation. A bean action needs a resolver. The first two forms leave lookup disabled. The third borrows the resolver and its returned objects, whose lifecycles belong to the application. The engine still discovers and constructs extensions through service declarations.
See Application components and actions for the complete setup.
The following fragment assumes the application supplies both XML definitions, input, and the corresponding format modules:
try (ProcessEngine engine = ProcessEngineFactory.create()) { engine.execute(ProcessDefinition.inline(ProcessModelType.TBBPM, "order", orderXml), input).orElseThrow(); engine.execute(ProcessDefinition.inline(ProcessModelType.BPMN, "payment", paymentXml), input).orElseThrow();}When Core auto-configuration is enabled and no application-defined ProcessEngine exists, Spring Boot creates and closes the engine and resolves business beans in the application context. Workbench Server includes both format modules; its PROCESS target uses the ordinary engine, while its DURABLE target uses the separate Durable engine.
See Resource management for shutdown order, timeout handling, and supplied resources.
Use engine.runtime() to manage local runtimes and engine.tooling() to check definitions or inspect generated source.
Both objects share the engine’s configuration and lifecycle.
| Accessor | Return type | Operations |
|---|---|---|
engine.runtime() |
ProcessRuntimeManager |
Warm runtimes, load and unload versions, manage local bindings |
engine.tooling() |
ProcessTooling |
Check definitions and inspect generated Java source |
2. Process Identity And Content
Section titled “2. Process Identity And Content”ProcessDefinition supplies an explicit definition source; ProcessRef identifies an exact version or a published Alias:
ProcessRef.Version version = ProcessRef.version("order.validate", "2026-07-25.1");ProcessRef.Alias alias = ProcessRef.alias("tenant-a", "order.validate", "production");Versionselects one exact immutable version, bound locally or supplied by a deployment control plane.Aliaschooses a version through its configured stable/candidate route.
Overloads without a namespace use ProcessRef.DEFAULT_NAMESPACE, whose value is fixed at "default".
Factories and record constructors validate identities without trimming or normalization. Namespace and process code have a limit of 128 characters; Version and Alias have a limit of 64. Each must start with an ASCII letter or digit, and may otherwise contain only ASCII letters, digits, ., _, and -. An explicit null or empty namespace is invalid. Namespaces separate logical resources; they do not perform authorization.
A ProcessRef does not contain source content.
ProcessDefinition describes how content is supplied or located with an explicit model type, but without namespace, version, or alias:
ProcessDefinition inline = ProcessDefinition.inline(ProcessModelType.TBBPM, "order.validate", xml);ProcessDefinition classpath = ProcessDefinition.classpath(ProcessModelType.TBBPM, "order.validate", "flows/order.bpm");The engine uses the model type specified by the definition; it does not infer the format from the content or filename.
toString() hides inline content. Inline content must be nonblank, valid Unicode. A classpath resource is a resource name, not a filesystem path or URL: construction replaces backslashes with /, removes empty and . segments, rejects .., and requires a nonblank normalized name. The definition loader handles classpath access, UTF-8 decoding, and source-size checks.
The API root package provides ProcessDefinitionDigest for stable definition digests and ProcessIdentifiers for identifier
validation without rewriting. Common’s UnicodeText supplies general Unicode validation and strict UTF-8 encoding and decoding.
Engine errors use CompileFlowException and ErrorCode. A nested call that exceeds the configured maximum call depth uses CF_EXEC_013;
the implementation-specific exception is not a public API. These public types and their documented behavior form part of the 2.x Java API contract.
3. Execution
Section titled “3. Execution”Input variables use Map<String, ?>, so callers can also pass a map such as Map<String, String>. Outputs use Map<String, Object>:
ProcessResult<Map<String, Object>> execute( ProcessRef ref, Map<String, ?> variables, ProcessExecutionOptions options);
ProcessResult<Map<String, Object>> execute( ProcessDefinition definition, Map<String, ?> variables, ProcessExecutionOptions options);Pass a non-null map (use Map.of() when no inputs are needed). The input map for execute(...) may contain only variables declared as param by the process. Missing parameters keep their model defaults;
a key with a null value explicitly supplies null. A return, inner, or undeclared key produces CF_VALIDATION_001.
trigger(...) starts a new call from the selected entry point. Its map may initialize any declared root variable,
but undeclared keys are still rejected. Use the Durable APIs to start a Run or complete a Durable Wait or event.
For a successful invocation, result.getExecution().getReachedTrigger() identifies the actual Wait entry at which
execution stopped, or is empty after reaching the normal end. It is not a persisted continuation or an authorization.
The caller owns the state and decides whether to start a later invocation at that entry.
The engine reads the input map and the objects it references. Callers must not modify them while execution is in progress, and Actions must not write back through those references. Do not assume the engine makes deep copies or freezes input objects. It returns declared outputs in a separate top-level map.
Both map-based forms have overloads with default options. Typed overloads follow the same execution path,
using the ProcessDataMapper selected through extension discovery to convert input before execution and output afterward:
<I, O> ProcessResult<O> execute( ProcessRef ref, I input, Class<O> outputType, ProcessExecutionOptions options);
<I, O> ProcessResult<O> execute( ProcessDefinition definition, I input, Class<O> outputType, ProcessExecutionOptions options);For example:
ProcessDefinition definition = ProcessDefinition.classpath(ProcessModelType.TBBPM, "order.validate", "flows/order.bpm");ProcessResult<Map<String, Object>> result = engine.execute(definition, Map.of("orderId", "A-42"));Use an exact Version or Alias reference to execute a published flow. A Version can also be bound locally with
runtime().load(ref, definition) without Deploy publication. Inline and classpath definitions resolve their explicit
source; they do not look up a “latest version”.
4. Request Metadata
Section titled “4. Request Metadata”ProcessExecutionOptions sets execution options such as the invocation ID. For an Alias invocation, it also accepts a routing key and routing attributes:
ProcessExecutionOptions options = ProcessExecutionOptions.builder() .invocationId("request-42") .aliasRouting(new AliasRoutingOptions( "opaque-cohort-key", Map.of("region", "cn-hangzhou"))) .build();Non-empty Alias routing options are not accepted for a direct definition or an exact Version. A null or empty routing key means no explicit cohort key; for ordinary Alias calls, the engine uses the effective invocation ID. A non-empty routing key is preserved verbatim, including whitespace. Keys and attribute values must be valid Unicode. Routing inputs are not copied into process variables or execution attribution, and must not be exposed in logs, metrics, or HTTP responses. Attribute names cannot be blank, contain surrounding whitespace, ISO control or Unicode format characters, or equal alias, version, namespace, processCode, or routingKey, or begin with __cf_. Attributes are copied into an immutable map. Do not modify the source map while the options are being constructed. The options object’s string representation includes attribute names, so use non-sensitive names and do not log the object. Null entries and duplicate names under string equality are rejected with IllegalArgumentException; a null attribute map is treated as empty, and empty string values are allowed.
| Field | Limit |
|---|---|
| Routing key | At most 512 Unicode code points |
| Routing attributes | At most 32 attributes; names up to 128 Unicode code points and values up to 2,048 |
| All routing inputs | At most 32 KiB in total for the UTF-8 bytes of the key, attribute names, and attribute values |
| Invocation ID | Optional; at most 128 characters when supplied. Starts with an ASCII letter or digit and contains only ASCII letters, digits, ., _, :, @, or - |
A supplied invocation ID is validated as written, without normalization or trimming. Surrounding whitespace is rejected. When it is absent, the engine generates a UUID string for this invocation. The invocation ID is used for attribution and, if needed, Alias routing; it is not an idempotency key for ProcessEngine.execute or trigger. Reusing it does not prevent another execution.
5. Results And Errors
Section titled “5. Results And Errors”ProcessResult<T> reports success or failure and includes execution details in ProcessExecution.
The result container is immutable; objects referenced by its output may still be mutable:
boolean isSuccess();boolean isFailure();T getOutput();ProcessError getError();ProcessExecution getExecution();<U> ProcessResult<U> map(Function<? super T, ? extends U> mapper);T orElse(T fallback);T orElseGet(Supplier<? extends T> fallback);T orElseThrow();<X extends Throwable> T orElseThrow(Supplier<? extends X> exceptionSupplier) throws X;Missing required arguments, invalid options, or an engine state that disallows the call cause an exception to be thrown directly.
Handled execution and mapping errors are returned in ProcessResult. It does not capture every Throwable; see the Failure Model.
A successful result has output, and a failed result has a ProcessError; it never has both. Successful output may be null,
so call isSuccess() to determine the outcome instead of checking getOutput(). ProcessError codes must start with A-Z, contain only A-Z, 0-9, ., _, or -, and have at most 128 characters. Messages must be nonblank valid Unicode and have at most 4,096 code points. Applications constructing a ProcessError must supply a message without sensitive data;
the constructor validates text and length but does not redact arbitrary business content.
map() transforms successful output (including null) and otherwise preserves the error and execution details. Exceptions from the mapper propagate to the caller, since it runs after execution. On failure, orElse() and orElseGet()
return a fallback value without error details; the original ProcessResult remains unchanged. Use them only when that fallback is acceptable to the application.
orElseThrow() returns successful output or raises ProcessExecutionException on failure; the supplier overload lets you choose your application’s exception type:
Map<String, Object> output = result.orElseThrow(() -> new IllegalStateException( result.getError().getCode() + ": " + result.getError().getMessage()));ProcessExecution contains the trace ID, invocation ID, namespace, process code, optional exact version, start and completion times, and the reached trigger entry. getReachedTrigger() returns Optional<ProcessTrigger>. A successful invocation with no reached entry ran to its normal end. If an invocation reaches a Wait but its subsequent output mapping fails, the failed result still preserves that entry.
It excludes root selection parameters, Alias routing details and inputs, model/source diagnostics, variables, and exception objects.
6. Triggered Entry Points
Section titled “6. Triggered Entry Points”ProcessTrigger selects an entry by its node ID, which must be unique within the selected definition, and an optional event:
ProcessTrigger trigger = ProcessTrigger.on("paymentReceived", "approved");ProcessResult<Map<String, Object>> result = engine.trigger( ProcessRef.alias("default", "order.process", "production"), trigger, Map.of("orderId", "A-42"), ProcessExecutionOptions.defaults());trigger(...) uses the same loading, routing, and result handling as execute(...), but starts a new in-memory execution at the selected node.
It does not resume a persisted Run or provide message persistence, correlation, or state recovery.
Use ProcessTrigger.at(nodeId) for a TBBPM waitTask without an event, or ProcessTrigger.on(nodeId, event) for a waitTask with an event or a supported BPMN message entry. The event is required for on; it is the declared TBBPM event or the referenced BPMN message name, not its declaration ID. An unqualified TBBPM waitTask matches by node ID and does not filter an event supplied by the caller; a declared event requires an exact match. The node ID and any supplied event must be nonblank valid Unicode, at most 512 code points each, without surrounding whitespace, ISO control or Unicode format characters.
7. Local Administration And Tooling
Section titled “7. Local Administration And Tooling”| Operation | Return value or completed work | Effect on local runtimes |
|---|---|---|
preflight |
A report containing stage results | May reuse the cache; does not install or retain a new runtime or bind a Version |
generateJavaCode |
Compiled-backend Java source | Does not switch backends or install a runtime |
warmUp |
Prepared runtimes for the supplied definitions | Caches runtimes without Version bindings |
load |
The supplied definition bound to the selected Version | Creates a local binding and idempotently retains it for this manager |
unload |
The current manager’s hold released | Removes bindings with no remaining owners; other owners or bindings may retain the runtime |
Manage local runtimes
Section titled “Manage local runtimes”Use engine.runtime() to warm local runtimes or load and unload a specific version:
void warmUp(ProcessDefinition... definitions);void load(ProcessRef.Version ref, ProcessDefinition definition);void unload(ProcessRef.Version... refs);warmUp prepares the supplied definitions and puts their runtimes in the local cache. It does not create or change process-code or Version bindings.
Cache limits and eviction still apply: when warming several definitions, an earlier entry may be evicted before the operation finishes.
load binds a Version to the supplied definition and retains that binding for the current manager. Repeating the same reference and content
does not require an additional unload call. It loads only the supplied definition, without installing or checking the entire
child-process call graph. Referenced child versions must be made available separately.
Both methods manage local runtimes; they do not publish durable state or change an Alias. Each Version must always refer to the same model type and exact content, including after unloading, restarting, or loading in another engine. The caller or publishing service must maintain this rule. The engine can detect conflicts with resident bindings, but it does not keep a permanent version registry. Use a new Version for changed content.
unload releases the current manager’s hold on a binding and removes it when no other owner retains it. Other owners may still use that binding,
and other bindings may share the same runtime. Unloading does not cancel running calls or guarantee immediate JVM class unloading.
The caller or publishing service must continue to keep each Version bound to the same model type and exact content.
Once the last owner releases a binding, the engine does not guarantee retaining the history needed to detect a later
load of that Version with different content.
unload validates the array and every member before releasing anything. A null array or member throws NullPointerException.
An empty array does nothing while the engine is open; a closing engine still rejects new calls. This argument check does not provide
transactional rollback if a runtime failure occurs. The control plane creates and changes Aliases through rollouts; unload does not retire an Alias. Use ProcessDeploymentService.retireAlias(RetireAliasCommand) to retire the authoritative Alias.
Preflight and source generation
Section titled “Preflight and source generation”engine.tooling() returns ProcessTooling for preflight and source generation without invoking process actions:
ProcessPreflightReport preflight( ProcessDefinition definition, ProcessPreflightOptions options);String generateJavaCode(ProcessDefinition definition);Preflight options and reports use these APIs:
| Type | Method signature | Purpose |
|---|---|---|
ProcessPreflightOptions |
static ProcessPreflightOptions fast(); |
Select LINT |
ProcessPreflightOptions |
static ProcessPreflightOptions strict(); |
Select LINT and RUNTIME_CHECK |
ProcessPreflightReport |
ProcessPreflightReport.OverallStatus getOverallStatus(); |
Read the overall PASS or FAIL result |
LINT checks process structure and the semantic rules shared by execution modes. RUNTIME_CHECK checks whether the selected ProcessEngine
backend can prepare the definition. Use builder().lintEnabled(...).runtimeCheckEnabled(...) to choose stages; at least one must be enabled.
COMPILED prepares generated process Java. INTERPRETED prepares an execution program and may also compile action or expression adapters.
Preflight may reuse a cached runtime that exactly matches the definition. Without a cache entry, any runtime created for the check is not
installed in the cache, bound to a Version, or retained for execution. Preflight does not invoke process actions.
To check a Durable process and its complete static dependency graph, use DurableProcessEngine.tooling();
a successful ProcessEngine preflight does not establish Durable support.
fast() and strict() both default to a one-minute deadline. The builder accepts another positive, whole-millisecond Duration.
Read the settings with isLintEnabled(), isRuntimeCheckEnabled(), and getTimeout().
Preflight checks only the supplied root definition, not its transitive process-call dependencies. Each definition produces a ProcessPreflightReport. Its getItems() method lists stage diagnostics, with PASS, FAIL, or TIMEOUT
from each item’s getStatus(). A failed or timed-out stage makes the overall result FAIL.
Use warmUp or load when you need runtimes ready for execution; successful preflight does not perform either operation.
Both COMPILED and INTERPRETED modes can generate source for inspection.
Generated source can contain business logic and must be handled as sensitive diagnostic output.
8. Configuration And Data Mapping
Section titled “8. Configuration And Data Mapping”ProcessEngineConfig provides a builder for immutable configuration snapshots:
static ProcessEngineConfig.Builder builder();The builder configures executor capacity, caches, the runtime backend, definition loading, observability,
class loading, and the source of Alias routes. Extensions such as the data mapper use @ExtensionRealization and
service declarations; building the configuration does not discover or construct them.
Spring reads external properties at startup and creates the same immutable configuration objects.
ProcessDataMapper converts between application objects and the process variable map:
Map<String, Object> toVariables(Object input);<T> T fromVariables(Map<String, ?> variables, Class<T> targetType);fromVariables borrows the supplied map and its reachable values; implementations must not mutate them.
It accepts maps with specific value types, such as Map<String, Integer>.
The keys returned by toVariables must match the calling API: execute accepts only param variables;
trigger can initialize any declared root variable. The engine validates the map against the actual definition and rejects extra keys.
Mapping errors are reported as engine errors. Output mapping runs after the process; a conversion failure does not undo side effects already produced by its Actions.
9. Extension SPI
Section titled “9. Extension SPI”compileflow-api defines the process extension interfaces; compileflow-common supplies discovery, invocation, and lifecycle management.
Annotate implementations with @ExtensionRealization, provide public no-argument constructors, and list their class names,
one per line, in META-INF/services/com.alibaba.compileflow.common.extension.Extension.
Each engine creates and manages its own instances. It does not accept Spring extension beans or application-created extension objects.
The public protocol consists of Extension<C extends ExtensionContext>, method-level @ExtensionPoint(code=...),
@ExtensionRealization(priority=...), ExtensionManager, and ExtensionInvoker.
Candidates are ordered by descending priority, then ascending binary class name. Fixed single and named lookups reject ties at the highest priority.
An ExtensionInvoker call with a context reevaluates support(context) on every invocation.
See the Extension Guide for service declarations, selection, shutdown, and thread-safety requirements.
ProcessAliasRouteSource is a separately configured source of routing data. The engine uses local Alias routing state by default.
To replace it, supply a source through aliasRouteSource(...) or a Spring bean.
The engine uses only that source; it does not merge local routes or fall back to them on failure.
The application manages this dependency, which is not declared in the extension service file.
10. Deployment API
Section titled “10. Deployment API”Use compileflow-deploy-api to manage process versions and routes. ProcessDeploymentService publishes immutable versions
and changes traffic through rollout commands that check revisions. Publishing a version does not install its runtime or route traffic to it.
Rollback creates a new rollout and preserves the existing history. retireAlias records a completed RETIRE rollout with no target Version; the captured baseline can be restored through rollback. Promote or abort an active canary before retirement. getAlias returns the retired state with its positive revision and no stable Version; an empty result means the Alias has never been created. To reactivate it, create an all-at-once rollout using that revision.
Create rollout commands with CreateRolloutCommand.allAtOnce(alias, target, expectedAliasRevision) or
canary(alias, target, initialWeightBps, expectedAliasRevision), followed by .idempotencyKey(...), .actor(...),
optional .notes(...) and canary .targeting(...), then .build(). For an existing rollout, weight updates,
promotion and abort use expectedRolloutRevision; rollback takes (sourceRolloutId, expectedAliasRevision, idempotencyKey, actor).
Use RolloutQuery.builder(limit) for optional filters and continuation cursors.
DeploymentException.getCommitOutcome() distinguishes NOT_COMMITTED, COMMITTED, and UNKNOWN independently
of getErrorCode(). NOT_COMMITTED describes this attempt, not any earlier attempt using the same command. A committed command can fail during projection or local installation; an unknown outcome
must be reconciled before retrying a revision-checked mutation.
Applications use this module’s commands and query results instead of depending on control-plane repositories or runtime implementation packages.
For an exact published version that may not be installed locally, use ProcessVersionRuntime.acquireInstallation(version)
from com.alibaba.compileflow.deploy.api.runtime on the runtime node. Hold the returned VersionRuntimeLease until
execution finishes, then close it. The lease’s version() identifies the exact retained version, not whether the lease is still open.
This installs the complete call graph without changing Alias traffic.
Spring Boot supplies this API in the embedded topology and whenever the Core runtime worker role is enabled. Control-plane-only deployments do not supply it.
See execute an exact published version.
Transport payloads, parsers, canonical JSON codecs, and projection keys are supplied by compileflow-deploy-protocol;
compileflow-deploy-api does not depend on that module.
11. Durable Process API
Section titled “11. Durable Process API”Use compileflow-durable-api for processes that need persistence and recovery. It provides its own DurableProcessEngine.
Adding the Durable starter does not change ProcessEngine.execute(...): those calls remain synchronous and are not automatically persisted.
Applications use the following interface without depending on a storage implementation:
public interface DurableProcessEngine extends AutoCloseable { void startWorkers(); void stopWorkers(); CompletionStage<Void> stopWorkersAsync(); WorkerState workerState(); void close();
ProcessRun start(ProcessRunId runId, ProcessDefinition definition, Map<String, ?> input); ProcessRun start(ProcessRunId runId, ProcessRef process, Map<String, ?> input); ProcessRun start(ProcessRunId runId, ProcessRef.Alias alias, Map<String, ?> input, AliasRoutingOptions options); ProcessRun completeWait(WaitToken waitToken, Map<String, ?> result); ProcessRun completeWait(ProcessRunId expectedRunId, WaitToken waitToken, Map<String, ?> result); ProcessRun cancel(ProcessRunId runId); Optional<ProcessRun> getRun(ProcessRunId runId); ProcessRunPage listRuns(ProcessRunQuery query); ProcessRunResult getRunResult(ProcessRunId runId);
DurableOperatorService operator(); DurableProcessTooling tooling(); RunHoldAuthority executionHolds(String trustedAuthorityId);}Starting and stopping the Worker
Section titled “Starting and stopping the Worker”startWorkers() starts this node’s Workers; repeated calls are idempotent. start(runId, ...) submits a business Run.
stopWorkers() stops Workers from acquiring new work and waits up to the configured limit for existing work to finish.
If the limit expires, unfinished Workers are interrupted and the call reports failure. Restarting Workers requires that the previous Workers have actually exited.
Business requests can still be submitted. stopWorkersAsync() completes only after the set of Workers captured by that call has actually exited. This is a node-local lifecycle signal, not proof that external work has stopped.
A custom engine that reports shutdown failure through exceptional completion must still wait for those Workers to exit.
workerState() returns the node-local lifecycle state: DISABLED (no local workers configured),
STOPPED (no active worker generation), RUNNING (work acquisition started), or STOPPING
(new acquisition is stopping and the worker generation has not yet terminated).
This observation is not a health or progress guarantee. Await stopWorkersAsync() for actual termination of the captured generation.
close() stops accepting new calls, drains admitted application operations, then stops Workers and releases local resources. If Workers outlive the drain budget, close reports failure and resources are retained until they actually exit. Call close from the application lifecycle owner, not from an active operation or engine-owned callback. The application remains responsible for a shared Store it supplied.
start, completeWait, and cancel return a Run snapshot after their operation commits. They do not imply that the whole process has finished.
cancel records a stop request, which is handled according to the stop policy saved when the Run was created. Use getRunResult to check the final outcome.
Starting a process and retrying requests
Section titled “Starting a process and retrying requests”The caller assigns a ProcessRunId for each new Run. Never reuse that ID for another execution, even after the original record’s retention period.
While the original creation record is retained, retrying start(runId, ...) with the same definition source or process reference,
effective routing options, and typed input returns the original Run. Its first stored definition, dependency bindings, and stop policy still apply,
even if the Alias has since changed or been retired. For a classpath definition, a retained retry uses the original resource path and does not reread the resource.
A different creation request, or a Run without the creation record this API uses to identify retries, produces RUN_ALREADY_EXISTS.
Retried input is checked against the first stored definition. Invalid typed input is reported as an input error, not a creation conflict.
After a timeout or another ambiguous response, finding the Run with getRun(runId) confirms that creation committed.
An empty result cannot establish that it never committed. Keep the original Run ID and creation parameters;
the API does not guarantee permanent request deduplication after the creation record expires.
The process source is fixed when the Run is created:
- An explicit definition is safely loaded and saved as an immutable snapshot.
- A Version selects that exact version, without falling back to another source.
- An Alias is resolved once, and the Run is permanently bound to the selected stored Process.
AliasRoutingOptionsapplies only when creating a Run through an Alias. A null or empty routing key uses the Run ID; attribute ordering does not affect retry identity.- Recovery reads the stored Process by
processId; it does not resolve the Alias again or read current classpath content.
The application must supply a DurableVersionDefinitionSource before starting by Version; Alias starts also require a DurableAliasStateSource.
See Durable configuration for supplying these sources through Spring beans or the Java builder.
Completing a Wait and reading results
Section titled “Completing a Wait and reading results”completeWait submits the complete result for the Wait identified by its WaitToken. Its keys must exactly match the source fields declared by that Wait’s outputs;
missing or extra fields are rejected. A Wait with no outputs accepts only an empty result. Values must match the mapped target variables’ types and nullability rules.
This is not an arbitrary update to process variables: on recovery, only the declared output mappings and optional native Wait projections update the state. A Wait can write WaitOutcome.COMPLETED or TIMED_OUT to its outcomeVariable and the original Store resolution time to resolvedAtVariable. A timeout writes no business outputs. See Completion and timeout outcomes and Business correlation and time.
The call commits the Wait result without running subsequent steps synchronously. Workers read the result and execute those steps when the Run is eligible.
While the owning Run and completed Wait remain queryable, retrying with the same token and canonicalized result does not change state again; a different result causes a conflict. After the process has consumed the Wait result, retention cleanup can remove the completion record even while the Run is still active. The token then becomes invalid; this API does not provide a permanent completion receipt.
Treat the token as a credential: exclude it from logs, metric labels, browser-visible URLs, third-party metadata, and Workbench views.
If the host application has authorized access to a particular Run, use the overload with expectedRunId to require that the token belongs to that Run.
getRun and listRuns do not read business payloads. getRunResult returns NotFound, NotCompleted, Succeeded, Failed, or Cancelled;
Succeeded decodes the stored business output into an unmodifiable map with detached values. A terminal result does not establish that all external Effects have settled under a bounded-drain stop policy. NotFound has the same visibility limits as an empty getRun.
Failed means the business Run failed. Query failures and output-decoding failures are reported as exceptions.
Querying Run state and controlling execution
Section titled “Querying Run state and controlling execution”The public Run lifecycle is:
| Status | Meaning |
|---|---|
RUNNABLE |
Committed and awaiting a compatible Worker. |
RUNNING |
A Worker holds the lease for the current Turn. |
WAITING |
Waiting for external input, a timer to expire, or an Effect result. |
SUCCEEDED, FAILED, CANCELLED |
Terminal. |
ProcessRun.termination() records a stop request. It is absent when no request exists; otherwise, ProcessRunTermination contains
the database decision timestamp recorded with the request and its CANCELLED or FAILED kind. For each Run, the first request committed under its row lock wins.
Use termination.failureCode() and failureMessage() for a failure that has not yet reached a terminal state.
The Run’s final error fields are used only after terminal failure.
A stop request, ProcessRunControl, and the Run lifecycle record different information. ACTIVE permits execution.
Both PAUSE_REQUESTED and PAUSED block new Turns for normal process execution and new Effect dispatches. PAUSE_REQUESTED means a Worker
still holds Turn or Effect execution authority; PAUSED means none is currently outstanding.
Recovery and termination work can still be claimed during a pause. Timers, Wait completions, Outbox delivery,
reconciliation, cancellation, and maintenance continue. Reaching PAUSED does not establish the outcome of an uncertain external operation.
Managing Runs and checking process definitions
Section titled “Managing Runs and checking process definitions”The objects returned by operator() and tooling() share the engine’s call state and lifecycle and are managed by the engine.
| Interface | Responsibility | Methods |
|---|---|---|
DurableOperatorService |
Query Run state and diagnose problems | getRun, listRuns, getRunDefinition, listTimeline, listActiveWork |
DurableOperatorService |
Audited control and recovery | pauseRun, resumeRun, resolveEffect, getOutboxEvent, listOutboxEvents, resolveOutboxEvent |
DurableProcessTooling |
Check a process and all its static dependencies against Durable rules | prepare(ProcessDefinition), prepare(ProcessRef.Version) |
Engine and Operator getRun/listRuns follow the same query rules and share the default implementation’s query code.
Business callers can query through Engine; diagnostic and control components need only hold Operator.
Operator does not execute process actions or continuation turns, but its commands can change persisted Run state.
The host application still handles authentication and authorization. Automated controllers and human tools must both honor revision checks and audit requirements. Transport adapters provide authentication, resource authorization, required approvals, rate limiting, and audit. Authorize reads of original process definitions separately from status queries.
Query visibility and pagination
Section titled “Query visibility and pagination”getRunDefinition and getOutboxEvent return Optional for currently visible records in the requested scope.
getOutboxEvent(runId, eventId) only finds an event owned by that Run; absence does not prove that delivery never occurred.
listTimeline and listActiveWork require a currently visible parent Run: missing or retention-hidden parents fail with RUN_NOT_FOUND.
An empty page only means no matching items on that page. Cross-Run listRuns and listOutboxEvents return empty pages when nothing matches.
Java queries use typed keyset cursors. Transport adapters convert them into opaque page tokens. Run and Outbox cursors belong to their original normalized namespace, code and status filters. Page size may change. Changing filters requires a first-page query. These lists are live keyset traversals, not frozen snapshots.
Check a Durable definition
Section titled “Check a Durable definition”A successful tooling().prepare(...) returns Preparation with the root process code, model type, digest, and dependency count.
It checks the current definition and the capabilities available in this application. It does not register definitions, create Runs,
execute actions, or warm the recovery cache. Failure throws an exception instead of returning partial success.
Passing the check does not reserve execution capacity or guarantee that remote Workers are ready.
Hold execution by reason
Section titled “Hold execution by reason”executionHolds(trustedAuthorityId) provides execution holds for the specified trusted host authority. Each hold has an exact RunHoldRef identifying its cause; the audit reason is not its identity. Releasing one hold does not release other holds or an Operator pause. The object follows the engine lifecycle. Use change to apply a command, find to look up its retained original result, and state to read current admission state. An empty find does not prove the command was never applied.
If the engine or its Store does not support this capability, the call throws UnsupportedOperationException. The trusted authority ID must match the authority frozen by the original Run admission policy.
Each retained RunHoldResult includes the original command’s AuditPrincipal actor and exact reason,
including on ADD, RELEASE, lookup, and replay. The actor is bounded to 128 Unicode scalar values; the reason
contains 1 to 512 Unicode scalar values and is preserved without trimming or normalization, including U+0000
and supplementary-plane characters. A replay preserves the original result bytes, identity, and time;
changing the actor or reason while reusing the command identity is conflicting intent.
The PostgreSQL provider retains these audit values in the existing canonical result bytes and Journal fact,
then verifies the reconstructed command intent, result digest, and Journal agreement when reading them.
These facts remain available only while the Run’s hold records are retained. Host authentication,
authorization, and audit policy remain the host’s responsibility; the recorded actor does not grant authority.
Child calls, Outbox, and errors
Section titled “Child calls, Outbox, and errors”bpmCall and callActivity create ProcessInvocation frames within the same Run, without an independently queryable child Run.
Outbox delivery can repeat and may arrive out of order; receivers must deduplicate by stable eventId.
See Outbox failures for failed deliveries, exhausted retries, and operator actions.
Handle DurableProcessException by its DurableErrorCode, not by parsing the message. An action’s execution="replayable|effect"
setting determines how it is executed and recovered. An Effect with an UNKNOWN outcome follows its configured recovery policy.
When reviewRequired() is true, an authenticated operator must resolve it.
See the Durable Process guide for creation requests, Wait tokens, child calls, operations, and recovery.
12. Failure Boundary
Section titled “12. Failure Boundary”Return types follow the operation’s meaning:
| Operation | Normal return | Absence or failure |
|---|---|---|
| Optional single-resource lookup | Optional<T> |
Empty for no currently visible record; query failures throw |
| Collection query | Page or collection | Empty when no items match; queries requiring a parent report missing parents separately |
Ordinary execute / trigger |
ProcessResult<T> |
Discriminates success and failure; successful output may be null |
| Durable result query | ProcessRunResult |
Uses its five branches; query failure is not a Run Failed outcome |
| Command or lifecycle operation | Success receipt or void | Throws if it cannot complete the required operation |
ProcessEngine preflight |
ProcessPreflightReport |
Definition-check failures appear in stage diagnostics; invalid arguments or engine state can still cause exceptions |
An Optional object is never null. An empty lookup or page means that no matching record is currently visible.
Unavailable storage, corrupt data, and failed commands are reported as errors.
The ProcessEngine returns handled execution and mapping errors in ProcessResult. Invalid arguments or an engine state that disallows the call
cause the method to throw its documented NullPointerException, IllegalArgumentException, or IllegalStateException.
Other classified engine failures use CompileFlowException and ErrorCode; Durable operations use DurableProcessException and DurableErrorCode.
CompileFlowException may include diagnostic context for troubleshooting. Do not use that context as the source of business state.
It is limited to 32 entries, 128-character keys, 2,048-character text values, and 32 collection elements.
Mutable collections are snapshotted; unsupported or oversized values are replaced by a fixed omission marker.
Diagnostics must not include process variables, payloads, source, or credentials, and must not change the execution outcome.
Do not log raw variables, source content, routing keys, credentials, full local paths, or arbitrary application objects when handling or reporting either kind of error.