Backend Development 7 min read

What Is Compileflow and How Can It Supercharge Your Java Workflow Engine?

Compileflow is a lightweight, high‑performance Java workflow engine that converts BPMN files into compiled code, offering seamless integration, visual process design, and extensive plugin support, with quick‑start instructions, code examples, and a concise summary of its advantages and current limitations.

macrozheng
macrozheng
macrozheng
What Is Compileflow and How Can It Supercharge Your Java Workflow Engine?

What is Compileflow

Compileflow is a lightweight, high‑performance, integrable and extensible workflow engine. It is one of Alibaba’s TBBPM engines, focusing on pure‑memory, stateless execution by converting BPMN files into Java code that is compiled and run. It powers many core systems in Alibaba’s middle‑platform.

Developers can design business processes with a visual editor, turning complex logic into visual diagrams that bridge business designers and engineers.

Feature List

High performance : Converts workflow files into compiled Java code for concise and efficient execution.

Rich application scenarios : Used across Alibaba’s middle‑platform for shopping guide, transaction, fulfillment, finance and more.

Easy integration : Lightweight design makes it straightforward to embed in various solutions.

Plugin support : IntelliJ IDEA and Eclipse plugins generate Java code in real time, providing a “what‑you‑see‑is‑what‑you‑get” experience.

Exportable SVG diagrams and unit‑test code.

Supports Java reflection and Spring‑container‑based code triggers.

Quick Start

Add the Compileflow Maven dependency:

<code>&lt;dependency&gt;
    &lt;groupId&gt;com.alibaba.compileflow&lt;/groupId&gt;
    &lt;artifactId&gt;compileflow&lt;/artifactId&gt;
    &lt;version&gt;1.0.0&lt;/version&gt;
&lt;/dependency&gt;
</code>

Create a simple process diagram with the designer.

Generated Java Code Example

<code>public class PigFlow implements ProcessInstance {
    private Integer price = null;

    public Map<String, Object> execute(Map<String, Object> _pContext) throws Exception {
        price = (Integer) DataType.transfer(_pContext.get("price"), Integer.class);
        Map<String, Object> _pResult = new HashMap<>();
        decision8();
        // AutoTaskNode: payment
        ((BizMock) ObjectFactory.getInstance("com.example.compileflow.bean.BizMock")).payMoney(price);
        _pResult.put("price", price);
        return _pResult;
    }

    private void decision8() {
        // DecisionNode: calculate fee
        bizMockCalMoney();
        if (price >= 100) {
            // ScriptTaskNode: discount 50%
            IExpressContext<String, Object> nfScriptContext = new DefaultContext<>();
            nfScriptContext.put("price", price);
            price = (Integer) ScriptExecutorProvider.getInstance()
                .getScriptExecutor("QL").execute("price*2", nfScriptContext);
        } else {
            // ScriptTaskNode: discount 50%
            IExpressContext<String, Object> nfScriptContext = new DefaultContext<>();
            nfScriptContext.put("price", price);
            price = (Integer) ScriptExecutorProvider.getInstance()
                .getScriptExecutor("QL").execute("(round(price*0.5,0)).intValue()", nfScriptContext);
        }
    }

    private void bizMockCalMoney() {
        price = ((BizMock) ObjectFactory.getInstance("com.example.compileflow.bean.BizMock")).calMoney(price);
    }
}
</code>

Unit Test Example

<code>@Test
public void testProcess() throws Exception {
    String code = "pig";
    ProcessEngine<TbbpmModel> engine = ProcessEngineFactory.getProcessEngine();
    System.out.println(engine.getJavaCode(code));
    Map<String, Object> context = new HashMap<>();
    context.put("price", 10);
    Map<String, Object> execute = engine.execute(code, context);
    System.out.println(execute);
}
</code>

Summary

Compileflow is extremely easy to get started with, lowering the learning curve of workflow development.

The IDEA design plugin had compatibility issues with the 2021 version.

Generated unit‑test code depends on older JUnit versions and does not support JUnit 5.

References

Compileflow IDEA design plugin: https://github.com/compileflow/compileflow-designer-upgrade

Javabackend developmentWorkflow EngineProcess Automationcompileflow
macrozheng
Written by

macrozheng

Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.