触发后取消Camunda计时器事件的执行

时间:2017-06-23 16:46:45

标签: java camunda

我想以编程方式决定每个进程上的所有计时器事件,如果我真的希望它们在发生事件之后发生,那么它们就会触发。

我为正在调用的启动事件注册了一个监听器,我尝试终止ActivityExecution,但它无效。

我的听众看起来像这样:

public class StartEventDelegate implements DelegateListener<ActivityExecution> {
private ProcessEngineServices processEngine;

public CamundaStartEventDelegate(ProcessEngineServices processEngine) {
    this.processEngine = processEngine;
}

@Override
public void notify(ActivityExecution instance) throws Exception {
    LOG.debug("StartEvent triggered, eventName={}...", instance.getEventName());

    if (abortThisExecution(instance)) {
        LOG.info("Terminating instance");
        instance.end(true);
    }
}

当我运行它时,似乎在我调用instance.end(true)之后再次调用侦听器,但是第二次调用instance.end(true)失败。

2017-06-23T17:33:18,340 [DEBUG] pool-3-thread-1 [CamundaStartEventDelegate notify:50] StartEvent triggered, eventName=start...
2017-06-23T17:33:18,355 [INFO ] pool-3-thread-1 [CamundaStartEventDelegate notify:77] Terminating instance
2017-06-23T17:33:18,362 [DEBUG] pool-3-thread-1 [CamundaStartEventDelegate notify:50] StartEvent triggered, eventName=start...
2017-06-23T17:33:18,364 [INFO ] pool-3-thread-1 [CamundaStartEventDelegate notify:77] Terminating instance
2017-06-23T17:33:18,364 [ERROR] pool-3-thread-1 [context logError:156] ENGINE-16006 BPMN Stack Trace:
        StartEvent_1i6cslv (activity-end, ProcessInstance[13])
        StartEvent_1i6cslv

2017-06-23T17:33:18,365 [ERROR] pool-3-thread-1 [context logError:156] ENGINE-16004 Exception while closing command context: null
java.lang.NullPointerException: null
        at org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl.getFlowScopeExecution(PvmExecutionImpl.java:1448) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl.createActivityExecutionMapping(PvmExecutionImpl.java:1438) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityEnd.execute(PvmAtomicOperationActivityEnd.java:53) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityEnd.execute(PvmAtomicOperationActivityEnd.java:32) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.AtomicOperationInvocation.execute(AtomicOperationInvocation.java:89) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.invokeNext(CommandInvocationContext.java:125) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performNext(CommandInvocationContext.java:104) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:79) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:611) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:587) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityNotifyListenerEnd$1.callback(PvmAtomicOperationActivityNotifyListenerEnd.java:44) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityNotifyListenerEnd$1.callback(PvmAtomicOperationActivityNotifyListenerEnd.java:38) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl.continueExecutionIfNotCanceled(PvmExecutionImpl.java:1942) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl.dispatchDelayedEventsAndPerformOperation(PvmExecutionImpl.java:1891) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityNotifyListenerEnd.eventNotificationsCompleted(PvmAtomicOperationActivityNotifyListenerEnd.java:38) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityNotifyListenerEnd.eventNotificationsCompleted(PvmAtomicOperationActivityNotifyListenerEnd.java:24) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.core.operation.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:65) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.AtomicOperationInvocation.execute(AtomicOperationInvocation.java:89) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.invokeNext(CommandInvocationContext.java:125) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performNext(CommandInvocationContext.java:104) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:79) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:611) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:587) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl.end(PvmExecutionImpl.java:334) ~[camunda-engine-7.6.0.jar:7.6.0]
        at my.company.workflow.camunda.delegate.CamundaStartEventDelegate.notify(CamundaStartEventDelegate.java:78) ~[main/:?]
        at my.company.workflow.camunda.delegate.CamundaStartEventDelegate.notify(CamundaStartEventDelegate.java:36) ~[main/:?]
        at my.company.workflow.StartEventDelegate.notify(StartEventDelegate.java:31) ~[main/:?]
        at my.company.workflow.StartEventDelegate.notify(StartEventDelegate.java:20) ~[main/:?]
        at org.camunda.bpm.engine.impl.core.instance.CoreExecution.invokeListener(CoreExecution.java:95) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.core.operation.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:52) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.AtomicOperationInvocation.execute(AtomicOperationInvocation.java:89) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.invokeNext(CommandInvocationContext.java:125) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performNext(CommandInvocationContext.java:104) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:79) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:69) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:622) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:597) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.core.operation.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:58) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.AtomicOperationInvocation.execute(AtomicOperationInvocation.java:89) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.invokeNext(CommandInvocationContext.java:125) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performNext(CommandInvocationContext.java:104) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:79) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:69) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:622) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:597) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.core.operation.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:58) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.AtomicOperationInvocation.execute(AtomicOperationInvocation.java:89) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.invokeNext(CommandInvocationContext.java:125) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performNext(CommandInvocationContext.java:104) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:79) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:69) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:622) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:597) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.core.operation.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:58) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.AtomicOperationInvocation.execute(AtomicOperationInvocation.java:89) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.invokeNext(CommandInvocationContext.java:125) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performNext(CommandInvocationContext.java:104) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:79) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:69) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:622) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:597) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.core.operation.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:58) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.AtomicOperationInvocation.execute(AtomicOperationInvocation.java:89) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.invokeNext(CommandInvocationContext.java:125) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performNext(CommandInvocationContext.java:104) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:79) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:69) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:622) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:597) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.core.operation.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:58) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.AtomicOperationInvocation.execute(AtomicOperationInvocation.java:89) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.invokeNext(CommandInvocationContext.java:125) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performNext(CommandInvocationContext.java:104) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:79) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:611) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:587) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityStartCreateScope.scopeCreated(PvmAtomicOperationActivityStartCreateScope.java:39) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationCreateScope.execute(PvmAtomicOperationCreateScope.java:50) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationCreateScope.execute(PvmAtomicOperationCreateScope.java:24) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.AtomicOperationInvocation.execute(AtomicOperationInvocation.java:89) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.invokeNext(CommandInvocationContext.java:125) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performNext(CommandInvocationContext.java:112) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandInvocationContext.performOperation(CommandInvocationContext.java:79) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:611) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:587) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl.start(PvmExecutionImpl.java:231) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.start(ExecutionEntity.java:432) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:55) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:31) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:104) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:66) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.ProcessInstantiationBuilderImpl.executeWithVariablesInReturn(ProcessInstantiationBuilderImpl.java:156) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.ProcessInstantiationBuilderImpl.execute(ProcessInstantiationBuilderImpl.java:122) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.ProcessInstantiationBuilderImpl.execute(ProcessInstantiationBuilderImpl.java:118) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.jobexecutor.TimerStartEventJobHandler.startProcessInstance(TimerStartEventJobHandler.java:54) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.jobexecutor.TimerStartEventJobHandler.execute(TimerStartEventJobHandler.java:43) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.jobexecutor.TimerStartEventJobHandler.execute(TimerStartEventJobHandler.java:24) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.persistence.entity.JobEntity.execute(JobEntity.java:129) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.cmd.ExecuteJobsCmd.execute(ExecuteJobsCmd.java:99) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.cmd.ExecuteJobsCmd.execute(ExecuteJobsCmd.java:36) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24) ~[camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:104) [camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:66) [camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30) [camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobHelper.executeJob(ExecuteJobHelper.java:35) [camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobHelper.executeJob(ExecuteJobHelper.java:28) [camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobsRunnable.executeJob(ExecuteJobsRunnable.java:82) [camunda-engine-7.6.0.jar:7.6.0]
        at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:56) [camunda-engine-7.6.0.jar:7.6.0]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_121]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_121]
        at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121]

我在这里做错了什么?

0 个答案:

没有答案
相关问题