有没有办法用Java完成或跳过activiti用户任务? 我实现了一个TaskListener,但是当我调用这段代码时:
delegateTask.getExecution().getEngineServices().getTaskService().complete( task.getId() );
我得到了这个例外:
Caused by: org.activiti.engine.ActivitiException: UserTask should not be signalled before complete
at org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior.signal(UserTaskActivityBehavior.java:146)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.signal(ExecutionEntity.java:407)
at org.activiti.engine.impl.persistence.entity.TaskEntity.complete(TaskEntity.java:201)
at org.activiti.engine.impl.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:50)
at org.activiti.engine.impl.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:24)
at org.activiti.engine.impl.cmd.NeedsActiveTaskCmd.execute(NeedsActiveTaskCmd.java:59)
at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24)
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:57)
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31)
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40)[415:org.activiti.engine:5.17.0]
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35)[415:org.activiti.engine:5.17.0]
at org.activiti.engine.impl.TaskServiceImpl.complete(TaskServiceImpl.java:179)
at Proxy7b61ad98_bd2d_436d_94dd_1e7381cca64e.complete(Unknown Source)
答案 0 :(得分:1)
由于仍然实例化了上下文,因此无法在任务侦听器中完成任务。如果你想跳过任务,你应该使用网关。
仅在xml级别支持的另一个替代方案(未在建模器中公开)是使用以下博客中记录的跳过表达式语法:
https://blog.canang.com.my/2016/09/30/whats-activiti-skiptask-about/