今天学习了jbpm4 的timer使用,一直测试都不成功:配置如下:
如图,设置为5秒后自动到达escalation节点,部署完任务后调用:
ProcessInstance instance = super.executionService
.startProcessInstanceByKey("TimerTransition");
然后5s后获取当前位置:
ProcessInstance instance = super.executionService
.findProcessInstanceById("TimerTransition.260001");
System.out.println(instance.findActiveActivityNames().toString());
每次获取都是在节点guardedwait节点中,甚是郁闷。
后来想想才明白,我程序部署完后就停止了,不是web环境的,任务执行完了就停止了,job根本无法执行,后来改了如下:
ProcessInstance instance = super.executionService
.startProcessInstanceByKey("TimerTransition");
Job job = managementService.createJobQuery().timers()
.processInstanceId(instance.getId()).uniqueResult();
System.out.println("job到期:" + job.getDuedate());
// ProcessInstance instance = super.executionService
// .findProcessInstanceById("TimerTransition.910001");
try
{
Thread.sleep(5000);
} catch (InterruptedException e)
{
e.printStackTrace();
}
String name = instance.findActiveActivityNames().toString();
System.out.println("当前节点:" + name);
System.out.println("instanceId:" + instance.getId());
ok执行成功,成功自动运行到节点es
手机扫一扫
移动阅读更方便
你可能感兴趣的文章