Problem retrieving execution in an async service task execution

Hi,

I am trying to follow the example https://github.com/camunda/camunda-bpm-examples/tree/master/servicetask/service-invocation-asynchronous to implements a async rpc execution using a java embedded server and rabbitMQ + akka streams.

When the remote call is done, a message listener is waiting for a result message on the broker, that is signalled to the AbstractBpmnActivityBehavior task. Following the example, the engine().getRuntimeService().signal() is call using the execution.getId() retrieved during the sending phase. but it throws an BadUserRequestException: execution xxx doesn’t exist: execution is null .

My process is really simple, one unique activity with an async rpc call over rabbitmq. The activity is asynchBefore=true and asyncAfter=false.

Would it be possible that the execution ended directly when execute() returns ?

I am stuck. I must have missed something. Any help would be highly appreciated.

thanks
Emmanuel

Hi @emmanuel,

it’s hard to analyse your issue without your BPMN process and source code of the activity.

Can you please provide the process + source code or a failing test case?

Best regards,
Philipp

Hi,

I understand. I’ve made some progress. While investigating, I found out that the execution.getId() is failing when the reply (from the rpc) is coming back too quickly.If I increase the duration of the remote task, the problem disappears.

I suspect a transaction boundary issue: The rabbtitmq message is sent at the end of execute() before the transaction ends. if the reply arrives while the transaction is commiting, the reported error sounds understandable.

Marking the task as “async after” did not fix the problem. I don’t know well enough Camunda to identify a proper strategy to apply to fix this issue.

thanks
best regards
Emmanuel

Relevant post on similar issue and how to hook into post-transaction completion Notification on every process instance state change (to update the UI)

This was what I was looking for. thanks !