在工作流引擎中使用Quartz

在osworkflow中,Trigger Function是通过Quartz来实现的,我们看看
LocalWorkflowJob.java的实现代码:
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        //JobDataMap是在schedule开始前放入的
        JobDataMap data = jobExecutionContext.getJobDetail().getJobDataMap();
        //entryId是工作流实例号
        long id = data.getLong("entryId");
        //在流程定义中定义的trigger的id
        int triggerId = data.getInt("triggerId");
        String username = data.getString("username");
        Workflow wf = new BasicWorkflow(username);
        try {
            //执行真正的trigger
            wf.executeTriggerFunction(id, triggerId);
        } catch (WorkflowException e) {
            //this cast is a fairly horrible hack, but it's more due to the fact that quartz is stupid enough to have wrapped exceptions
            //wrap Exception, instead of Throwable.
            throw new JobExecutionException("Error Executing local job", (e.getRootCause() != null) ? (Exception) e.getRootCause() : e, true);
        }
    }

其实,我们在自己的工作流引擎或者系统中,还可以用Quartz实现更多的功能.
比如,我们有需求是要为流程或者活动指定时间限制,到该时间限制前10分钟
要向任务执行者告警,那么我们可以这样实现:
在服务器启动时启动scheduler,然后每1分钟,计算引擎中的流程实例还剩下的
时间,这个时间不需要持久化,直接记录在内存中,可以由引擎的其它部分读取.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值