I am trying to create a simple process with async operations.
Here is my sample process
start → serviceTask1 → serviceTask2 → end
Here my serviceTask1
and ServiceTask2
are a bit log running operations, and the from the service task, I am calling a method which returns Java Future
. I do not want to use blocking call by using .get
on Future and instead was trying to send the signal to camunda from the Future completion.
However, I am getting a NullPointerException on doing so.
java.lang.NullPointerException
at org.camunda.bpm.engine.impl.context.ProcessApplicationContextUtil.getTargetProcessApplication(ProcessApplicationContextUtil.java:115)
at org.camunda.bpm.engine.impl.context.ProcessApplicationContextUtil.getTargetProcessApplication(ProcessApplicationContextUtil.java:89)
at org.camunda.bpm.engine.impl.context.ProcessApplicationContextUtil.getTargetProcessApplication(ProcessApplicationContextUtil.java:51)
at org.camunda.bpm.engine.impl.bpmn.behavior.ClassDelegateActivityBehavior.signal(ClassDelegateActivityBehavior.java:77)
at org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl.signal(PvmExecutionImpl.java:726)
at com.reactore.hf.FuturePblm$.$anonfun$completeAndSendSignal$1(FuturePblm.scala:30)
at com.reactore.hf.FuturePblm$.$anonfun$completeAndSendSignal$1$adapted(FuturePblm.scala:27)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64)
at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
So for the time being, I thought of not using the Future operation and signal the task directly. I was expecting the task(serviceTask1) to get stuck and the process not going forward to serviceTask2 if I comment out the signal operation. However, it is not working as I expected.
public class CustomServiceTask extends AbstractBpmnActivityBehavior {
@Override
public void execute(ActivityExecution execution) throws Exception {
System.out.println("****Inside service task 1 ****");
execution.setVariable("inLineProcess", "test");
String procesInstanceId = execution.getProcessInstanceId();
execution.getProcessEngine().getRuntimeService().signal(procesInstanceId);
System.out.println("After sending signal from task 1 ");
// Thread.sleep(5000);
// leave(execution);
// FuturePblm.completeAndSendSignal(execution, FuturePblm.futureValue());
System.out.println(" after future");
}
}
Can someone let me know what I am doing wrong here? Or help me to handle the Future scenario from the service tasks ?
Is my understanding of signal
wrong ?
Note: For this test, I was creating the process programmatically, and tried asyncBefore and asyncAfter on the service tasks also.