该文章介绍flowable工作流,是一种较新的工作流引擎。因为在工作中用到了此工作流框架,而且网上相关资料较少,所以记录一下学习的过程,希望对后来学习的人有一定帮助。如有错误,还望指正。
Flowable 简介
![](https://i-blog.csdnimg.cn/blog_migrate/954601552e9a6337199e124b656d3eab.gif)
1. 什么是 flowable
- 中文官方帮助文档
- Flowable在Apache V2 协议下发布,Apache V2这个协议对商业非常友好。
- 所需环境:JDK1.8+,Eclipse neon/mars(集成Flowable Designer)
- 一句话涵盖flowable的核心功能:Flowable流程引擎可用于部署BPMN 2.0流程定义(用于定义流程的行业XML标准), 创建这些流程定义的流程实例,进行查询,访问运行中或历史的流程实例与相关数据
2. 工作流的几个概念
- 流程定义
- 流程实例
- 执行实例
- 任务实例
快速入门
![](https://i-blog.csdnimg.cn/blog_migrate/954601552e9a6337199e124b656d3eab.gif)
1. flowable 和 activiti 数据库表的对比
- 先创建流程配置实例,数据库使用MySQL,然后使用配置实例创建流程引擎实例。代码如下:
flowable的版本:
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-engine</artifactId>
<version>6.5.0</version>
</dependency>
public class HollyDayRequestApplication {
public static void main(String[] args) {
ProcessEngine instance = createProcessEngineConfiguration(creatConf());
}
// 创建流程引擎的配置中心
public static ProcessEngineConfiguration creatConf() {
ProcessEngineConfiguration configuration =
new StandaloneProcessEngineConfiguration()
.setJdbcDriver("com.mysql.jdbc.Driver")
.setJdbcUrl("jdbc:mysql://localhost:3306/2020flowable")
.setJdbcUsername("root")
.setJdbcPassword("123456");
// DB_SCHEMA_UPDATE_TRUE 如果数据库里面没有表,就创建
configuration.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
return configuration;
}
// 构建流程引擎的实例
public static ProcessEngine createProcessEngineConfiguration(ProcessEngineConfiguration configuration) {
return configuration.buildProcessEngine();
}
}
- 两者对比:
activiti 有 25 张表,而 flowable 表的数量要比 activiti 多很多。通过下图直观感受一下: