1. What is compileflow

Compileflow is a very lightweight, high performance, integrated and extensible process engine.

Compileflow Process engine is one of Taobao workflow TBBPM engines. It is a pure in-memory, stateless Process engine that converts flow files to Generate Java code for execution. Currently, it is the process engine of several core systems such as Alibaba business transactions in Taiwan.

Compileflow enables developers to design their own business processes through the process editor, visualizing complex business logic and bridging the gap between business designers and developers.

2. Function list

  1. High performance: Generated by converting process filesjavaCode compilation and execution, concise and efficient.
  2. Rich application scenarios: it is widely used in Alibaba zhongtai solution, supporting multiple business scenarios such as purchase guide, transaction, contract performance and capital.
  3. Integrability: Lightweight and concise design makes it extremely easy to integrate into various solutions and business scenarios.
  4. Complete plug-in support: Flow design is currently availableIntelliJ IDEA,EclipsePlug-in support, which can be dynamically generated in real time during process designjavaCode and preview, what you see is what you get.
  5. Export flow design diagramssvgFiles and unit test code.

3, Quick Start

Step1: download and installIntelliJ IDEAPlug-in (optional)

Download the plugin at github.com/alibaba/com…

Installation instructions: Please useIntelliJ IDEALocal installation method to install, restartIntelliJ IDEAIt goes into effect.

Step2: POMThe plug-in

<dependency>
    <groupId>com.alibaba.compileflow</groupId>
    <artifactId>compileflow</artifactId>
    <version>1.0.0</version>
</dependency>
Copy the code

The available version can be viewed at search.maven.org.

Note: Compileflow only supports JDK 1.8 and later.

Step3: Process design

The following uses KTV Demo as an example to explain how to configure nodes and attributes and use apis.

Demo description: N individuals to KTV singing, each sing a song, KTV consumption price is 30 yuan/person, if the total price is more than 300 10% off, less than 300 according to the original price payment.

S3.1

Create a BPM file as shown below:

Note:bpmThe file path must be andcodeTo be consistent, process engine execution in file load mode will be based oncodeFind the file.

S3.2

Design the process through plug-ins or write the process XML file directly.

S3.3 Call process

Write the following unit tests:

public void testProcessEngine(a) {
    final String code = "bpm.ktv.ktvExample";

    final Map<String, Object> context = new HashMap<>();
    final List<String> pList = new ArrayList<>();
    pList.add("wuxiang");
    pList.add("xuan");
    pList.add("yusu");
    context.put("pList", pList);

    final ProcessEngine<TbbpmModel> processEngine = ProcessEngineFactory.getProcessEngine();

    final TbbpmModel tbbpmModel = processEngine.load(code);
    final OutputStream outputStream = TbbpmModelConverter.getInstance().convertToStream(tbbpmModel);
    System.out.println(outputStream);
    System.out.println(processEngine.getTestCode(code));

    processEngine.preCompile(code);

    System.out.println(processEngine.start(code, context));
}
Copy the code

compileflowNative support taobao onlyBPMSpecification, for compatibilityBPMN 2.0Specification, made a certain adaptation, but only support partBPMN 2.0Element, which can be extended if supported by other elements.

4,For more information

  • DEMO Quick Start
  • Details of the original Taobao BPM specification