Asynchronous non-interrupting event sub-process block service task execution

Hello

Given a process:

[Reasons for process design:
This process spawns an asynchronous, non-interrupting, embedded event sub-process that runs a service task that prepare data that will be used in UserTask_1. It takes about 2 mins to complete the service task in the embedded sub-process. In the UI there is quite a couple of steps before the data would be needed (more than 2 mins of work).]

Issue:
The embedded sub-process finishes correctly. The problem is that after sending the message to start the embedded sub-process the ‘send message’ service task is blocked (does not continue, see image above). The ‘send message’ service task eventually times out and then gets re-tried.

All service tasks are async as well as the embedded sub-process.

Any ideas why this happens?

Code:
The code that sends the message (inside a JavaDelegate invoke camunda REST API):

    CamundaRestClient client  = new CamundaRestClient("sfeUser");
    Map<String, String> correlation = new HashMap<String, String>();
    correlation.put("processInstanceId", delegateExecution.getProcessInstanceId());
    client.sendMessage("INITFINGERPRINT",
            delegateExecution.getProcessBusinessKey(),
            new HashMap<String, String>(),
            correlation);
    delegateExecution.setVariable("send message", "done!!");

Appreciate!
Giovanni

Hi Giovanni,

to reproduce the problem we need some more specific data (like a bpmn file etc.).
Is it possible for you to implement an unit test and publish it on github?
You can use this project https://github.com/camunda/camunda-engine-unittest as a template.

Best regards,
Chris

Hi Chris

Thanks for the reply and tip! Will prepare a unit test case an post it.

Ciao
Giovanni

1 Like

Hello

I have created a fully functional POC with unit testing:

https://github.com/giovanniroos/camunda-poc.git

Run normally in camunda:
When I run the process it fails on the Send Message service task.

Running the unit test
It fails with NullPointerException (in camunda source) on the Send Message service task.

Question
It will be hugely appreciated if someone can explain to me why the process is failing.

Here is the stack trace from the unit test:

java.lang.NullPointerException
at org.camunda.bpm.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior.leave(AbstractBpmnActivityBehavior.java:62)
at org.camunda.bpm.engine.impl.bpmn.behavior.ServiceTaskJavaDelegateActivityBehavior.execute(ServiceTaskJavaDelegateActivityBehavior.java:41)
at org.camunda.bpm.engine.impl.bpmn.behavior.ClassDelegateActivityBehavior$1.call(ClassDelegateActivityBehavior.java:65)
at org.camunda.bpm.engine.impl.bpmn.behavior.ClassDelegateActivityBehavior$1.call(ClassDelegateActivityBehavior.java:62)
at org.camunda.bpm.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior.executeWithErrorPropagation(AbstractBpmnActivityBehavior.java:105)
at org.camunda.bpm.engine.impl.bpmn.behavior.ClassDelegateActivityBehavior.execute(ClassDelegateActivityBehavior.java:62)
at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityExecute.execute(PvmAtomicOperationActivityExecute.java:41)
at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationActivityExecute.execute(PvmAtomicOperationActivityExecute.java:26)
at org.camunda.bpm.engine.impl.interceptor.AtomicOperationInvocation.execute(AtomicOperationInvocation.java:81)
at org.camunda.bpm.engine.impl.interceptor.CommandContext.invokeNext(CommandContext.java:187)
at org.camunda.bpm.engine.impl.interceptor.CommandContext.performNext(CommandContext.java:166)
at org.camunda.bpm.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:141)
at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:589)
at org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:565)
at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationTransitionNotifyListenerStart.eventNotificationsCompleted(PvmAtomicOperationTransitionNotifyListenerStart.java:56)
at org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperationTransitionNotifyListenerStart.eventNotificationsCompleted(PvmAtomicOperationTransitionNotifyListenerStart.java:26)
at org.camunda.bpm.engine.impl.core.operation.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:65)
at org.camunda.bpm.engine.impl.interceptor.AtomicOperationInvocation.execute(AtomicOperationInvocation.java:81)
at org.camunda.bpm.engine.impl.interceptor.CommandContext.invokeNext(CommandContext.java:187)
at org.camunda.bpm.engine.impl.interceptor.CommandContext.performNext(CommandContext.java:166)
at org.camunda.bpm.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:141)
at org.camunda.bpm.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:131)

Hey Giovanni,

the problem with this use case is, that sending of messages and catching them in the same process instance is not fully supported by the specification. Thats why it is also not tested by camunda, but you can create a CAM issue for this. If you want, you can do a pull request with a fix of this issue. Also you can use escalation for this, see the documentation.

With the next release of the Camunda engine (7.6.0) we will support conditional events. With the help of conditional events that can also be done.

Best regards,
Chris

Hi Chris

Thank you for the feedback! Using escalation seem to be the right choice. Unfortunately we are still on camunda 7.1 which does not support escalations. Luckily we will upgrade to version 7.5 in about a months time :slight_smile:
For now I will send the message to the process from outside the process model in the java code.

Ciao
Giovanni