What is compileflow
Compileflow is a very lightweight, high-performance, integrable, and extensible process engine.
The compileflow Process engine is one of Taobao workflow TBBPM engines. It is a stateless process engine that focuses on pure memory execution. It converts process files to generate java code for compilation and execution, which is concise and efficient. Currently, it is the process engine of multiple core systems such as mid-stage transactions in Ali business.
Compileflow allows developers to design their own business processes through the process editor, visualize complex business logic, and build a bridge between business designers and development engineers.
function list
- High performance: It is simple and efficient to compile and execute java code generated by converting process files.
- Rich application scenarios: Widely used in Alibaba's mid-office solutions, supporting multiple business scenarios such as shopping guide, transaction, contract performance, and funding.
- Integrable: Lightweight and concise design makes it extremely easy to integrate into various solutions and business scenarios.
- Complete plug-in support: The process design is currently supported by IntelliJ IDEA and Eclipse plug-ins, and java code can be dynamically generated and previewed in real-time during the process design. What you see is what you get.
- Support process design drawing to export svg file and unit test code.
- Support code triggering based on Java reflection and Spring container
Get started quickly
- Introduce compileflow jar dependency
<dependency>
<groupId>com.alibaba.compileflow</groupId>
<artifactId>compileflow</artifactId>
<version>1.0.0</version>
</dependency>
- Draw a simple flow chart using compileflow
- View the compiled process business Java code ( following code is automatically generated by
public class PigFlow implements ProcessInstance {
private java.lang.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: 付款
((BizMock)ObjectFactory.getInstance("com.example.compileflow.bean.BizMock")).payMoney(price);
_pResult.put("price", price);
return _pResult;
}
private void decision8() {
//DecisionNode: 计算费用
bizMockCalMoney();
if (price>=100) {
//超过100
{
//ScriptTaskNode: 春哥请客 腿打折
IExpressContext<String, Object> nfScriptContext = new DefaultContext<>();
nfScriptContext.put("price", price);
price = (java.lang.Integer)ScriptExecutorProvider.getInstance().getScriptExecutor("QL").execute("price*2", nfScriptContext);
}
} else {
//不超过100
{
//ScriptTaskNode: 冷冷请客 打5折
IExpressContext<String, Object> nfScriptContext = new DefaultContext<>();
nfScriptContext.put("price", price);
price = (java.lang.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);
}
}
- Right click on the designed bpm file to create a unit test
@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);
}
- Perform process unit test and output target process
假装在计算金额~~~~~~10
支付了~~~~~~5
to sum up
- Compileflow is extremely easy to use, reducing the difficulty of workflow learning.
- compileflow IDEA design plug-in has compatibility issues in version 2021.
- The automatically generated unit test code depends on a low version and does not support Junit5
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。