前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >flowable实现节点超时自动跳过

flowable实现节点超时自动跳过

作者头像
星痕
发布2019-05-05 11:32:36
9.3K5
发布2019-05-05 11:32:36
举报
文章被收录于专栏:JAVA后端开发

不论是flowable还是activiti,都可以快速的实现节点超时自动跳过,主要是使用边缘事件

  1. 启动定时任务 在初始化时,启动定时job,写在配置文件如下
代码语言:javascript
复制
flowable:
  #启动定时任务JOB
    async-executor-activate: true
    check-process-definitions: false
    rest-api-enabled: false
    database-schema-update: true
    idm:
     enabled: false

注意: async-executor-activate就是开关

  1. 使用边缘事件 生成流程定义如下:
代码语言:javascript
复制
<userTask id="N5" name="审批" flowable:async="true" flowable:assignee="1,2,3">
      <multiInstanceLoopCharacteristics isSequential="false" flowable:collection="{starmark_emptycollection}" flowable:elementVariable="starmark_atuser"></multiInstanceLoopCharacteristics>
    </userTask>
    <boundaryEvent id="BoundaryEvent_N5" name="审批" attachedToRef="N5" cancelActivity="true">
      <extensionElements>
        <flowable:executionListener event="end" class="com.starmark.oa.workflow.activiti.listener.ProcessDueTimeListener"></flowable:executionListener>
      </extensionElements>
      <timerEventDefinition>
        <timeDate>PT1H</timeDate>
      </timerEventDefinition>
    </boundaryEvent>

上述就配置了1个小时自动跳过

  1. 实现监听器 从上述定义,可以看到,我配置了一个监听器. 为什么配一个监听器呢,主要是为了让自动跳过时,生成一条日记记录,不然自动跳过了,啥都不知道了. 当然,如果不考虑加日志,上面的配置已经可以定时跳过了
代码语言:javascript
复制
/**
 * 流程节点超时自动跳过
 */
public class ProcessDueTimeListener implements ExecutionListener {

    private IActHiCommentService actHiCommentService=null;

    private IActHiCommentService getActHiCommentService(){
        if(actHiCommentService==null){
            actHiCommentService=SpringContextUtils.getBean(IActHiCommentService.class);
        }
        return actHiCommentService;
    }

    @Override
    public void notify(DelegateExecution execution) {
        CommentEntity comment = new CommentEntityImpl();
        comment.setId(IdWorker.getIdStr());
        comment.setProcessInstanceId(execution.getProcessInstanceId());
        comment.setType("comment");
        comment.setAction(execution.getCurrentFlowElement().getName()+"超时自动跳过");
        comment.setTime(new Date());
        comment.setUserId("system");
        comment.setMessage("");
       System.out.println(execution.getProcessInstanceId());
        System.out.println( execution.getCurrentActivityId());
        getActHiCommentService().insert(comment);

    }
}
  1. 遗留问题:
  • 流程只支持节点超时自动跳过,但不支持任务超时自动跳过,如果需要实现,流程引擎不支持
  • 自动跳过是通过定时器的,但问题是定时器如果执行失败,没办法获取该失败原因,这个要怎么处理? 初步发现,全部的出错日志都记录到表act_ge_bytearray,后面再分析原因吧
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019.04.18 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档