CompileFlow architecture overview
CompileFlow runs the steps described in TBBPM or the supported subset of BPMN inside a Java application. The application supplies business methods; the definition determines their order, conditions, and branches. This page starts with one invocation, then explains how version deployment and persisted execution work.
One process invocation
Section titled “One process invocation”The application gives ProcessEngine a definition and input, then waits for the result:
ProcessDefinition definition = ProcessDefinition.classpath(ProcessModelType.TBBPM, "order.process", "flows/order.bpm");ProcessResult<Map<String, Object>> result = engine.execute(definition, Map.of("orderId", "A-42"));ProcessDefinition specifies the format, process code, and source. Inline supplies text directly; Classpath
reads a file from the application’s classpath. Input variables use Map<String, ?>; the returned variables use Map<String, Object>.
DTO overloads convert the input before the invocation and the output after successful execution.
The default COMPILED mode turns the definition into an executable Java object, called a runtime in these documents.
For a direct definition, the engine reads the source within its size limit and looks for matching content in the cache.
First use usually requires parsing, validation, Java generation, and compilation. Later calls can reuse the matching
runtime. A shared file name is therefore not enough to identify the same definition.
Concurrent requests for the same missing runtime share one preparation task. The engine retains the runtime until
the invocation ends, so eviction cannot replace it during execution. Cache capacity is limited; using an evicted
definition again may require recompilation. INTERPRETED mode executes the same process plan without generating a
process class. It still compiles Java expressions and action adapters as needed and prepares scripts through their
registered executors.
The internal cache key, ProcessRuntimeIdentity, also includes model type, process code, compilation pipeline, and
class loader. It is local to the engine, is not stored in a database, and does not identify portable compiled artifacts.
See Execution flow for the complete invocation.
Add components as needed
Section titled “Add components as needed”For execution inside the application process, add the required format module, such as compileflow-tbbpm; it brings in the engine and public API transitively. Choose optional
components according to the work the application needs to do:
| Need | Component | Responsibility |
|---|---|---|
| Call a process and obtain its result | Engine | Parse, prepare, cache, and execute definitions |
| Release versions and move traffic gradually | Deploy | Store immutable versions, change Alias routes, and prepare versions on runtime nodes |
| Wait for an external event or continue after restart | Durable | Save progress and let background Workers continue the execution |
| Edit and manage processes in a browser | Workbench | Provide the editor and operations UI, using backend APIs through Server |
ProcessEngine and DurableProcessEngine have separate entry points. ProcessEngine needs no deployment database;
Durable needs a Store for saved state. Workbench, Server, and Deploy are not prerequisites for embedding the engine.
The diagram shows what the components do during execution. For Maven modules, source directories, and Spring configuration, see the Module map.
Release a new process version
Section titled “Release a new process version”Supply a definition directly when the application manages its process files. Use Deploy when flows need independent releases, exact-version execution, or gradual traffic changes:
- Publish a definition as an immutable
ProcessRef.Version. - Create a rollout that points a
ProcessRef.Aliasto that version. For a new Alias, use an all-at-once rollout with an expected route revision of0. - Call a Version to use it explicitly, or call an Alias to let the route choose.
Publishing stores the immutable definition and related information; it neither compiles runtimes on execution nodes nor moves traffic. A live Alias has one stable version. A canary adds one candidate and a weight in basis points (1,000 means 10%). The default selector uses this weight; a named targeting policy can select the stable or candidate version directly. The routing key groups requests for selection and never becomes a process variable. The Alias revision orders route updates.
The control plane saves the route, rollout history, and audit in one transaction. EMBEDDED and DISTRIBUTED also
write a routing Outbox record so delivery can continue after a failure. AUTHORITY does not push routes to execution nodes:
Core workers poll their assigned Aliases, and new Durable Runs read the committed route when they start.
Receiving a route does not make a node ready to execute it. The node prepares every required version, checks that the revision has not changed, and only then enables that route. These documents call the newest received route desired and the route available for execution local-ready.
A preparation failure leaves the previous local-ready route in use. A node that has never prepared a usable route
rejects the request. Before running business code, the engine binds the root runtime and its complete static call graph. A CF_EXEC_012 acquisition failure permits one retry of that whole step only if the observed Alias route has changed or disappeared. A fixed Version is not rerouted. After successful binding, the invocation keeps its call graph even if the Alias changes.
Retiring an Alias records a higher revision without route targets. Core stops new Alias admissions after local convergence; Durable rejects new admissions that observe the retired authority. Already bound executions keep their runtimes. An explicit Version call does not consult the retired Alias, but it still requires its runtime to be installed. Retirement can release the installation demand previously held by the Alias; use an independent runtime lease when that version must remain available. A later all-at-once rollout can reactivate the Alias using its retired revision.
Rollback creates a new all-at-once rollout and preserves the previous records. See Hot deployment for commands and Version routing for selection and delivery.
Continue after a restart
Section titled “Continue after a restart”Consider an order process that waits for payment and then creates a shipment. The wait may be long, and the application
may restart while it is waiting. Starting it through DurableProcessEngine creates a Run whose progress is saved
in the Store.
A Worker claims a Run that has work to do, reads its last committed position and variables, executes the next steps, and commits the state needed to resume later. When payment arrives, the application saves the Wait result; a Worker continues the process afterward. External operations such as creating a shipment use an Effect to record the request and its outcome. If the call is interrupted, recovery must determine whether the external operation happened.
A Run can start from a definition, Version, or Alias. The Alias is resolved once, and the selected exact definition is saved. Recovery reads that definition and committed execution state; a later Alias change does not replace the process being recovered. Generated code, bytecode, and derived schemas can be rebuilt. The application still has to supply the business implementations the saved process uses.
Workers need a valid lease to update a Run’s execution state. One Store transaction saves the execution positions
of active branches and subprocess calls, markers for processed results, new requests, and Run state. Maintenance handles expired leases,
Timers, cancellation, and Outbox recovery. These mechanisms are separate from ProcessEngine invocations
and the Workbench queue for asynchronous whole-process calls.
Durable architecture follows a complete example through saving state, waiting, external operations, and recovery.
Configuration and extensions
Section titled “Configuration and extensions”ProcessEngineConfig holds immutable runtime settings and selects the Alias route source.
compileflow-common provides the extension framework, and compileflow-api defines process extension interfaces.
Implement an interface, annotate the class with @ExtensionRealization, and list it in
META-INF/services/com.alibaba.compileflow.common.extension.Extension.
Each engine’s ExtensionManager discovers these declarations and creates instances through public no-argument constructors.
Each extension point defines whether to use the highest-priority implementation, select by name or context, or invoke multiple implementations in order.
Spring Boot integration starts the engine and looks up business objects in the application’s ApplicationContext.
Plain Java applications can supply a ProcessComponentResolver through ProcessEngineFactory.create(config, resolver).
The application owns these business objects; the engine creates and manages its declared extension instances.
See the Extension guide for examples, selection rules, and resource ownership.
Each module reads its configuration and passes immutable settings to runtime components. The configuration guide lists application and Spring properties. Datasource, server, management, and logging keep Spring’s standard prefixes.
Default metrics limit the number of label values. Use diagnostics, structured logs, and traces to investigate individual invocations; keep business payloads and sensitive values out of metric labels.
Runtime and scope
Section titled “Runtime and scope”CompileFlow publishes Java 17 bytecode and requires a supported full JDK (17, 21, or 25) with jdk.compiler, including when using interpreted execution.
Generated source and bytecode also target Java 17. Java 21 and 25 can use virtual threads through the internal executor
strategy; the public API stays the same.
Definitions call application code, so run only trusted definitions. BPMN support is limited to the documented subset; the application manages human-task lifecycles. When evaluating performance, include initial preparation, definition reuse, and the work performed by application methods. See When to use CompileFlow for scenario selection and Supported surfaces for the full API and platform scope.