Skip to content
Development preview · 2.0.0-SNAPSHOT

CompileFlow Quick Start

Run a pricing flow in a plain Java application. It calls a Java method to calculate the price of three 500-cent items with a 10% discount and returns totalCents=1350. No Spring container, extra script module, database, or deployment service is required. Then use the same flow in your own application.

  • A full JDK 17, 21, or 25, including jdk.compiler. Both COMPILED and INTERPRETED use Java compilation facilities; generated bytecode targets Java 17.
  • The repository Maven Wrapper for the checkout commands below. A copied standalone application uses your own Maven installation.
  • JDK 21 or 25 for Checkstyle and the release-artifacts profile; these quality tools require Java 21 or newer.

From the repository root, check the toolchain:

Terminal window
java -version
./mvnw -version

The Maven Java version must be 17, 21, or 25. Maven may use a different JDK from java -version; select a supported JDK through your JDK manager or JAVA_HOME before continuing.

From the repository root, install the BOM and process format modules from source, then run the standalone Java example:

Terminal window
./mvnw install -pl :compileflow-bom,:compileflow-tbbpm,:compileflow-bpmn -am -DskipTests
cd examples/standalone
../../mvnw -B package org.apache.maven.plugins:maven-dependency-plugin:3.11.0:build-classpath \
-DincludeScope=runtime -Dmdep.outputFile=runtime-classpath.txt
java -cp "target/standalone.jar:$(cat runtime-classpath.txt)" \
com.alibaba.compileflow.examples.standalone.StandaloneConsumer

These launch commands use a Unix shell and classpath separator. The standalone guide also provides a cross-platform verification command and instructions for copying the application outside the repository.

Look for:

CF_STANDALONE_CASE COMPILED TBBPM totalCents=1350 actions=8
...
CF_STANDALONE_SUCCESS cases=4 invalidPreflights=2 closedRejections=2 actions=32

The sample checks both formats and both runtime modes, then closes its engines and exits. The next section shows a single process call.

The quote definition declares three input parameters and the return variable totalCents. Its class action calls a public instance method in PricingService. The engine creates the service through its public no-argument constructor.

The engine matches each input@target to a Java method parameter by name. To retain parameter names at compile time, add <maven.compiler.parameters>true</maven.compiler.parameters> under <properties> in the POM of the module that declares the methods.

With that class and flows/quote.bpm packaged in your application, the call is:

package example;
import com.alibaba.compileflow.engine.ProcessDefinition;
import com.alibaba.compileflow.engine.ProcessEngine;
import com.alibaba.compileflow.engine.ProcessEngineFactory;
import com.alibaba.compileflow.engine.ProcessModelType;
import java.util.Map;
public final class QuoteApp {
public static void main(String[] args) {
var definition = ProcessDefinition.classpath(
ProcessModelType.TBBPM, "standalone.quote.tbbpm", "flows/quote.bpm");
try (ProcessEngine engine = ProcessEngineFactory.create()) {
var result = engine.execute(definition,
Map.of("units", 3, "unitPriceCents", 500, "discountPercent", 10))
.orElseThrow();
System.getLogger(QuoteApp.class.getName()).log(System.Logger.Level.INFO,
"totalCents=" + result.get("totalCents"));
}
}
}

The log contains totalCents=1350. The short-lived program closes the engine with try-with-resources. A server should create one engine per configuration, reuse it across requests, and close it when the application shuts down. See Resource management.

Use the process’s input parameter names as map keys. An omitted parameter uses the default declared in the definition. An explicit null stays null. Treat the map and its values as read-only during execution.

To call objects that your application already owns, supply a ProcessComponentResolver to ProcessEngineFactory.create(config, components) and use a bean action. The application keeps ownership of the resolver and business objects. See how the standalone example calls existing objects.

Add the following configuration to your application’s pom.xml, merging existing elements where necessary. The BOM aligns dependency versions; it does not add dependencies or require a CompileFlow parent POM. The compiler plugin is included explicitly so the example does not depend on Maven’s default compiler version.

<properties>
<maven.compiler.release>17</maven.compiler.release>
<maven.compiler.parameters>true</maven.compiler.parameters>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.alibaba.compileflow</groupId>
<artifactId>compileflow-bom</artifactId>
<version>2.0.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.alibaba.compileflow</groupId>
<artifactId>compileflow-tbbpm</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.16.0</version>
</plugin>
</plugins>
</build>

Copy the linked PricingService.java into src/main/java/com/alibaba/compileflow/examples/standalone/ and quote.bpm into src/main/resources/flows/quote.bpm. Save the QuoteApp above to src/main/java/example/QuoteApp.java. Keep the pricing class’s original package because the definition references its fully qualified class name.

From your application’s root directory, build and run it (using a Unix shell):

Terminal window
mvn -B package org.apache.maven.plugins:maven-dependency-plugin:3.11.0:build-classpath \
-DincludeScope=runtime -Dmdep.outputFile=runtime-classpath.txt
java -cp "target/classes:$(cat runtime-classpath.txt)" example.QuoteApp

Confirm that the output contains totalCents=1350.

Use compileflow-bpmn for BPMN, or include both format modules when needed. The complete standalone POM includes both formats and the Common API used by its listener. Core includes the Java script executor. Add a QLExpress or MVEL implementation only when the definition uses that language.

execute(...) returns a ProcessResult; orElseThrow() returns its output or throws for a failed result. Missing required arguments, invalid options, or a closed engine that no longer accepts calls can also cause an exception directly.

Typed execute(..., input, Output.class) calls use the same variable-map pipeline. Input mapping happens before execution; an input-mapping failure returns CF_EXEC_010. Output mapping happens after the invocation returns normally at End or an ordinary Wait. If conversion fails with a RuntimeException, the call returns CF_EXEC_009; the execution information still identifies any reached trigger. Conversion does not undo side effects that have already occurred.

An execution failure can also follow earlier successful business actions. Do not automatically rerun an entire flow just because isFailure() is true. Classify the failure and check the original business outcome or idempotency contract before retrying an operation with external effects.

Use engine.tooling().preflight(...) to check a definition without executing business actions. For frequently used definitions, engine.runtime().warmUp(...) prepares and caches runtimes in that engine.

Both preflight and warmup operate on the supplied root definition; they do not recursively check or prepare child processes. fast() preflight does not prepare a runtime. strict() can reuse a matching cached runtime; a new runtime prepared only for a strict check is not added to the cache. Warmup does not bind a Version or change an Alias. See Check and prepare a process for the complete calls.

Need Entry Additional responsibility
Execute a trusted definition inside the application Direct: ProcessEngine.execute(definition, ...) Package the definition and Java bindings; own the engine lifecycle. No crash recovery is implied.
Publish immutable versions and choose traffic through Aliases Deploy-managed ProcessEngine with Version/Alias references Publish a Version, then change its Alias with the expected revision; the selected runtime must be installed locally before it is used. Publication alone does not save in-flight execution.
Persist waits, timers, external operations, and restart recovery DurableProcessEngine and a supported Store Own the Store and workers, preserve original Run/operation identities, and define action recovery semantics.

COMPILED and INTERPRETED select an execution backend. They do not switch Direct execution into Durable execution.

The quote example uses an ordinary action without an execution declaration. Durable rejects it with DURABLE_ACTION_EXECUTION_REQUIRED. Before migrating, address the following:

  • Use execution="replayable" for computations that are safe to repeat. Use execution="effect" for external operations and configure reconciliation, idempotent retry, or manual resolution. Mark an action replayable only if repeating it cannot cause additional business effects.
  • Use a stable ProcessRunId and preserve its association with the original business request. Reopening or retrying admission must not silently create a different business operation.
  • Supply durable notification delivery and application authorization for Wait completion. Persisting a Wait does not provide a human-task or webhook application.
  • Preserve the original definition and required application types/bindings. Settling one Effect without unrelated types does not guarantee that the whole Run can resume without its execution materials.

Ordinary ProcessEngine rejects Effect actions, Timers, and Wait result/deadline features that require Durable. Follow Durable process, Hot deployment, and When to use CompileFlow rather than treating the paths as interchangeable settings.

For an existing Spring Boot application, use a matching starter with the supported Spring Boot version. The basic Spring sample uses a QLExpress addition flow. From the repository root:

Terminal window
./mvnw install -pl :compileflow-spring-boot-starter-tbbpm,:compileflow-script-qlexpress -am -DskipTests
./mvnw -f examples/spring-boot-basic/pom.xml spring-boot:run

Its log reports Sample process completed: result=42. The sample README contains the definition, application source, and context-test command.

Import the CompileFlow BOM in your application and add compileflow-spring-boot-starter-tbbpm; add compileflow-script-qlexpress only for QLExpress flows. For BPMN use compileflow-spring-boot-starter-bpmn. For both formats, combine compileflow-spring-boot-starter, compileflow-tbbpm, and compileflow-bpmn.

The BOM manages CompileFlow, Jackson 3, Tomcat, and MySQL Connector/J versions; your application still selects its Spring Boot platform and test dependencies. When importing spring-boot-dependencies, put the CompileFlow BOM first. If you inherit spring-boot-starter-parent, also set tomcat.version and, for MySQL applications, mysql.version as documented in the BOM guide. A child-imported BOM cannot override versions declared directly by that parent. Validate any intentional version overrides.