Flowable 6.4.x工作流

本文介绍Flowable流程引擎的集成与应用实践,包括Flowable的概念、Spring Boot项目的集成方式、流程引擎的配置方法、流程部署与启动的示例,以及如何实现Java Delegate。

Flowable是19年基于activity开出的分支,大多业务场景只是使用activity走线上请假审核流程,实际上大厂里对flowable的使用更多是高并发状态下流程化、模板化功能开发。

一、概念

1、先贴6.4.x的中文版用户手册
https://jeesite.gitee.io/front/flowable/6.4.2/bpmn/index.html
2、Flowable是一个使用Java编写的轻量级业务流程引擎。
这就给Flowable更好的结合现在java微服务生态提供了可能。

二、集成开发

1、cse集成flowable

上文说到flowable是由java编写的,那么集成在spring、springboot、serviceCobm都是非常轻松的。
这里以serviceCobm为例展示,集成spring的案例官网就有,自不必多多说。
1.1引cse框架包

  <dependencyManagement>
    <dependencies>
      <!--cse-->
      <dependency>
        <groupId>org.apache.servicecomb</groupId>
        <artifactId>java-chassis-dependencies</artifactId>
        <version>${servicecomb.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

1.2 引入flowable6.x.x 最新版已经到了6.6.0,查看了官网的升级介绍,对其中部分API做了更新,但大部分逻辑没有发生改变。

  <!--flowable start-->
    <dependency>
      <groupId>org.flowable</groupId>
      <artifactId>flowable-engine</artifactId>
      <version>6.4.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.flowable/flowable-spring -->
    <dependency>
      <groupId>org.flowable</groupId>
      <artifactId>flowable-spring</artifactId>
      <version>6.4.0</version>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.uuid</groupId>
      <artifactId>java-uuid-generator</artifactId>
      <version>3.1.3</version>
    </dependency>
    <!--flowable end-->

三、配置流程引擎及服务引擎

配置流程引擎,有2中方式。

3.1 代码配置流程引擎

import lombok.Data;
import org.flowable.engine.*;
import org.flowable.engine.impl.cfg.StandaloneProcessEngineConfiguration;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
 * 功能说明
 *
 * @author asky
 * @date 2021/7/18 0018 7:22
 */
@Configuration
@ConfigurationProperties(prefix = "spring.datasource")
@Data
class ProcessEngineConfig {
   
   

    @Value("${spring.datasource.url}")
    private String url;

    @Value("${spring.datasource.driver-class-name}")
    private String driverClassName;

    @Value("${spring.datasource.username}")
    private String username;

    @Value("${spring.datasource.password}")
    private String password;

    /**
     * 初始化流程引擎
     * @return
     */
    @Primary
    @Bean(name = "processEngine")
    public ProcessEngine initProcessEngine() {
   
   

        // 流程引擎配置
        ProcessEngineConfiguration cfg = null;

        try {
   
   
            cfg = new StandaloneProcessEngineConfiguration()
                    .setJdbcUrl(url)
                    .setJdbcUsername(username)
                    .setJdbcPassword(
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

旧梦昂志

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值