最近在研究BPM, 发现了flowable这个框架.
用的版本是docker版本的flowable/all-in-one, 当时的镜像版本是6.5.0.
为了图省事, docker run以后, 我把容器中的tomcat目录全部复制出来了, 然后再配置下java的一些环境变量啥的(如果有就不用配置了), 就相当于全部安装完了.
其中包括4个web应用:
拿来探索之后, 做了如下修改:
上面介绍的4个web应用用的数据源都是H2, 此数据库是完全基于内存的, 重启tomcat数据就没了.
所以改成mysql的方便做实验, 不然每次都得重新创建/导入数据.
首先要创建一个数据库(我这里就叫flowable)
$ cat tomcat/conf/context.xml
<Context>
<WatchedResource>
WEB-INF/web.xml
WatchedResource>
<WatchedResource>
WEB-INF/tomcat-web.xml
WatchedResource>
<WatchedResource>
${catalina.base}/conf/web.xml
WatchedResource>
<Resources cachingAllowed="true" cacheMaxSize="100000" />
<Resource auth="Container"
name="jdbc/flowableDS"
type="javax.sql.DataSource"
description="JDBC DataSource"
url="jdbc:mysql://localhost:3306/flowable?useUnicode=true&characterEncoding=utf8"
driverClassName="com.mysql.jdbc.Driver"
username="root"
password="******"
defaultAutoCommit="false"
initialSize="5"
maxWaitMillis="5000"
maxTotal="120"
maxIdle="5"/>
Context>
然后在上述4个应用的对应配置文件中打开datasource的jndi配置.
如对modeler而言
$ cat tomcat/webapps/flowable-modeler/WEB-INF/classes/flowable-default.properties
spring.datasource.jndi-name=jdbc/flowableDS
配置好以后, 重新启动tomcat, 会发现flowable数据库中多了很多表出来, 说明配置成功了.
flowable支持邮件任务, 但是前提是要配置好邮件发送服务.
由于是task应用发邮件的, 所以改task应用的配置, 找到mail相关的, 改成合适的值:
$ cat tomcat/webapps/flowable-task/WEB-INF/classes/flowable-default.properties
flowable.mail.server.host=smtp.qq.com
flowable.mail.server.port=25
[email protected] # 我的qq邮箱
flowable.mail.server.password=xxx # qq邮箱现在需要什么授权码, 这个在qq邮箱设置页可以获得.
配置好上面的以后, 我制作了一个简单的流程, 包括邮件任务, 测试可以发送成功.
上面是流程图, 其中"发送邮件"是一个邮件任务. 其xml表示为:
cat 模型-发送邮件.bpmn20.xml
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:flowable="http://flowable.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.flowable.org/processdef">
<process id="model_send_mail" name="模型-发送邮件" isExecutable="true">
<startEvent id="startEvent1" flowable:formFieldValidation="true">startEvent>
<userTask id="sid-4BF3E2A0-FFD8-4CA8-B008-61D781BBFDE2" name="输入邮件内容等" flowable:candidateGroups="admin" flowable:formKey="model_send_mail" flowable:formFieldValidation="true">
<extensionElements>
<modeler:group-info-name-admin xmlns:modeler="http://flowable.org/modeler">modeler:group-info-name-admin>
<modeler:activiti-idm-candidate-group xmlns:modeler="http://flowable.org/modeler">modeler:activiti-idm-candidate-group>
<modeler:initiator-can-complete xmlns:modeler="http://flowable.org/modeler">modeler:initiator-can-complete>
extensionElements>
userTask>
<sequenceFlow id="sid-4C9E3145-C9B1-4B3C-A9B3-6E9A85479223" sourceRef="startEvent1" targetRef="sid-4BF3E2A0-FFD8-4CA8-B008-61D781BBFDE2">sequenceFlow>
<serviceTask id="sid-7A166748-2174-4F8E-AA4F-B7C4B9685D18" name="发送邮件" flowable:type="mail">
<extensionElements>
<flowable:field name="to">
<flowable:expression>flowable:expression>
flowable:field>
<flowable:field name="from">
<flowable:expression>flowable:expression>
flowable:field>
<flowable:field name="subject">
<flowable:expression>flowable:expression>
flowable:field>
<flowable:field name="text">
<flowable:expression>flowable:expression>
flowable:field>
<flowable:field name="html">
<flowable:expression>flowable:expression>
flowable:field>
extensionElements>
serviceTask>
<sequenceFlow id="sid-1B68CF6A-9A0E-4F93-8A65-1395A351933C" sourceRef="sid-4BF3E2A0-FFD8-4CA8-B008-61D781BBFDE2" targetRef="sid-7A166748-2174-4F8E-AA4F-B7C4B9685D18">sequenceFlow>
<endEvent id="sid-04CBB505-2748-45C6-B942-04C3BAB802F4">endEvent>
<sequenceFlow id="sid-AA574C01-41E8-4AAC-BF46-99F8860F414E" sourceRef="sid-7A166748-2174-4F8E-AA4F-B7C4B9685D18" targetRef="sid-04CBB505-2748-45C6-B942-04C3BAB802F4">sequenceFlow>
process>
definitions>
启动流程之后, 用户填写表单, 输入收件人, 邮件主题等, 然后确定.
输入的值会传递给邮件任务, 然后自动发邮件.
vim tomcat/webapps/flowable-idm/WEB-INF/classes/flowable-default.properties
找到ldap相关配置
#
# LDAP
#
flowable.idm.ldap.enabled=true
flowable.idm.ldap.server=ldap://192.168.3.3
flowable.idm.ldap.port=389
flowable.idm.ldap.user=cn=admin,dc=example,dc=com
flowable.idm.ldap.password=xxxxxx
flowable.idm.ldap.base-dn=dc=example,dc=com
flowable.idm.ldap.user-base-dn=ou=Account,dc=example,dc=com
flowable.idm.ldap.group-base-dn=ou=Group,dc=example,dc=com
# 查找用户, {0{为uid, 根据实际情况书写查询条件
flowable.idm.ldap.query.user-by-id=(&(objectClass=inetOrgPerson)(uid={0}))
# 根据用户全名来查找用户
flowable.idm.ldap.query.user-by-full-name-like=(&(objectClass=inetOrgPerson)(|({0}=*{1}*)({2}=*{3}*)))
# 查找所有用户
flowable.idm.ldap.query.all-users=(objectClass=inetOrgPerson)
# 查找用户所属的组, 这个没配置出来, 可以忽略
flowable.idm.ldap.query.groups-for-user=(&(objectClass=posixGroup)(memberUid={0}))
# 列出所有组
flowable.idm.ldap.query.all-groups=(objectClass=posixGroup)
# 根据组id获取组
flowable.idm.ldap.query.group-by-id=(&(objectClass=posixGroup)(cn={0}))
# 各个属性取哪个字段
flowable.idm.ldap.attribute.user-id=uid
flowable.idm.ldap.attribute.first-name=cn
flowable.idm.ldap.attribute.last-name=sn
flowable.idm.ldap.attribute.email=mail
flowable.idm.ldap.attribute.group-id=cn
flowable.idm.ldap.attribute.group-name=cn
flowable.idm.ldap.attribute.group-type=cn
flowable.idm.ldap.cache.group-size=10000
flowable.idm.ldap.cache.group-expiration=180000
https://jeesite.gitee.io/front/flowable/6.5.0/bpmn/index.html