Hi there.
I have a timer that is starting a process periodically. But since I’m running Camunda in a cluster and I only want to run this process on a single node so I have a listener for the start
event which checks if that particular execution is already being processed by another node and if it is, I want to skip the execution on the current node.
I tried deleting the deleteProcessInstance(...)
but I get a NullPointerException
,
My code is something like this (simplified. This would terminate every timer execution):
public class CamundaStartEventDelegate implements DelegateListener<ActivityExecution> {
@Override
public void notify(ActivityExecution instance) throws Exception {
if (!startedByTimer(instance)) {
return;
}
processEngine.getRuntimeService().deleteProcessInstance(instance.getProcessInstanceId(), "Ran in another node");
}
But I get this error:
2017-06-22T17:38:20,856 [ERROR] pool-3-thread-1 [context logError:156] ENGINE-16006 BPMN Stack Trace:
null (activity-start, ProcessInstance[13])
StartEvent_1i6cslv
2017-06-22T17:38:20,857 [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.core.operation.AbstractEventAtomicOperation.getListeners(AbstractEventAtomicOperation.java:78) ~[camunda-engine-7.6.0.jar:7.6.0]
at org.camunda.bpm.engine.impl.core.operation.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:37) ~[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]
Does anybody have any idea why I can’t do this?