最近公司的项目须要升级acitiviti到flowable,作了好多的准备工做,总结一下,分享给须要爱学习的人。mongodb
1.修改配置文件数据库
flowable.database-schema-update=truejson
2.从 act_re_model 复制到 act_de_model架构
INSERT INTO act_de_model(id,NAME,model_key,last_updated,created,VERSION,tenant_id,model_type,model_editor_json,created_by,last_updated_by) SELECT id_ AS id,name_ AS NAME,key_ AS model_key,LAST_UPDATE_TIME_ AS last_updated,CREATE_TIME_ AS created,VERSION_ AS VERSION,TENANT_ID_ AS tenant_id,0 AS model_type,META_INFO_ AS model_editor_json, 'admin' as created_by,'admin' as last_updated_by FROM act_re_model;并发
3.同步model的数据app
@Test public void testSyncModelDatas() throws Exception { List<Model> list = repositoryService.createModelQuery().list(); int i = 0; for (org.flowable.engine.repository.Model model : list) { i++; byte[] modelEditorSource = repositoryService.getModelEditorSource(model.getId()); org.flowable.ui.modeler.domain.Model m = modelService.getModel(model.getId()); if (m != null) { try { JsonNode editorNode = new ObjectMapper().readTree(modelEditorSource); m.setModelEditorJson(editorNode.toString()); modelService.saveModel(m); } catch (Exception e) { e.printStackTrace(); } } } }
4.监听器兼容处理dom
public class BusinessCallListener implements TaskListener { private static final long serialVersionUID = -5140234938739863473L; protected Logger logger = LoggerFactory.getLogger(getClass()); /** * dubbo的类名 */ private Object clazzName; /** * 方法名 */ private Object method; /** * 版本号 */ private Object version; /** * 参数 多个的话用分号隔开 实例 userCode:00004737;status:1 */ private Object params; @Override public void notify(DelegateTask delegateTask) { String clazzNameStr = ""; String methodStr = ""; String versionStr = ""; String paramsStr = ""; if (clazzName instanceof FixedValue){ clazzNameStr = ((FixedValue) clazzName).getExpressionText(); }else if(clazzName instanceof org.activiti.engine.impl.el.FixedValue) { clazzNameStr = ((org.activiti.engine.impl.el.FixedValue) clazzName).getExpressionText(); } if (method instanceof FixedValue){ methodStr = ((FixedValue) method).getExpressionText(); }else if(method instanceof org.activiti.engine.impl.el.FixedValue) { methodStr = ((org.activiti.engine.impl.el.FixedValue) method).getExpressionText(); } if (version instanceof FixedValue){ versionStr = ((FixedValue) version).getExpressionText(); }else if(version instanceof org.activiti.engine.impl.el.FixedValue) { versionStr = ((org.activiti.engine.impl.el.FixedValue) version).getExpressionText(); } if (params instanceof FixedValue){ paramsStr = ((FixedValue) params).getExpressionText(); }else if(params instanceof org.activiti.engine.impl.el.FixedValue) { paramsStr = ((org.activiti.engine.impl.el.FixedValue) params).getExpressionText(); } IDynamDubbo dynamDubbo = SpringContextHolder.getBean("dynamDubboImpl"); ExecutionEntity execution = ExecutionHelper.getExecution(delegateTask.getProcessInstanceId()); String businessKey = execution.getBusinessKey(); try { Map<String, Object> paramMap = new HashMap<>(); paramMap.put("businessKey", businessKey); if (StringUtils.isNotBlank(paramsStr)) { String[] ps = paramsStr.split(";"); if (ps != null && ps.length > 0) { for (String p : ps) { String[] split = p.split(":"); if (split != null && split.length > 0) { paramMap.put(split[0], split[1]); } } } } String paramsJson = JsonUtils.toJson(paramMap); //执行dubbo方法 logger.debug("开始调用业务系统接口" + clazzNameStr + "." + methodStr + ",业务参数:" + paramsJson); dynamDubbo.invoke(clazzNameStr, methodStr, versionStr, paramsJson); } catch (Exception e) { logger.error("调用业务系统的方法失败", e); //添加容错信息 FlowBuesinessException fbe = new FlowBuesinessException(clazzNameStr, methodStr, versionStr, businessKey, e.getMessage()); this.createWfBuesinessException(fbe); } } //添加容错信息 private void createWfBuesinessException(FlowBuesinessException fbe){ IFlowBuesinessExceptionService flowBuesinessExceptionService = SpringContextHolder.getBean("flowBuesinessExceptionServiceImpl"); try { flowBuesinessExceptionService.insertFlowBuesinessException(fbe); } catch (Exception e) { e.printStackTrace(); } } }
5. flowable-ui-modeler 集成分布式
这个太多了,后面作一个系统讲解ide
6.集成效果微服务
6.1 自定义表单
6.2 流程在线编辑
6.3. 门户对接
7. 集成mongodb 提高查询已办任务和我发起的流程实例
为何集成mongodb?
咱们的历史任务并非不少,当我在150w的时候,查询已办任务和我发起的流程就至关慢,已办任务足足耗时3分钟,这个没法知足咱们的业务需求,无奈之下才集成mongodb的,如今查询的速度在0.005s以内,提高性能上万倍。
大大提高了用户体验。
7.1. 按照flowable提供的实例直接在mongodb里面生成本身的相关表,可是他在你关系数据库中就不会生成数据了
7.2.按照本身约定的规则把流程实例和流程任务和其余表关联的信息存放到mongodb中,方便查询
我这边采用的是第二种方式
8.当前的数据量
改版上线以后大大提高了流程的对接效率和指定行之有效的流程策略。
天天以5-10的流程模板递增,1500个业务表单提交,6500个处理任务。
9.流程中心将来发展
因为当前的流程中心是基于flowable作的二次封装,因此也会一直更新flowable的版本,跟官方一致。
流程中心采用微服务分布式集群架构,因此对高并发大数据里无任何影响。
目标是支持公司至少天天10w个表单提交,80w个待办任务处理,1w个流程模板。