How to complete a “Receive Task action” after parallel gateway

Hello guys, I am new here, and I am starting to develop processes with camunda, it is really nice.

I have a process like this, and I want to write a Junit Test for this process.

I am stuck at the receive task action. I’ve tried many ways to say to the engine that the message is received, but I am failing so hard. Most of the times I receive a report like

org.camunda.bpm.engine.MismatchingMessageCorrelationException: Cannot correlate message 'fpiComplete': No process definition or execution matches the parameters

I have already read message and task documentation, have already tried the snippets there, have already tried different ways to do that with the Runtime Service, have already tried to follow as this and I am still not able to complete my receive task.

There is an Advice in Receive Task documentation warning this:

Correlation of a parallel multi-instance isn’t possible because the subscription can’t be identified unambiguously.

It can be related to my problem? I mean, I am not using multi-instance, or are the parallel gateway splits considered as multi instances?

Hey there @vitor.ap
Welcome to the forum.
Could upload your model and the unit test you’re using to step through it?

For sure, I can!
I have just created a simplified version to emulate this behavior.

Here is the BPMN
process.bpmn (7.9 KB)

Here are my Test Package Java classes

If you prefer, here is the simple springboot project I made to emulate this behavior.

At a glace it looks like you’ve added a bunch of Asynchronous Before/After on tasks. This would complete the transaction and create a job for the enjoy to pick up.
During testing the engine’s job executor is turned off wouldn’t pick them back up. You need to explicitly complete the job before it will more to the receive task.
Take a look at these docs for more details:

1 Like

First, thanks for you replying.

You are right, It was needed to complete the job. Your comment was really helpful and it led me to study a series of new subjects that I had not studied at camunda.

Now I have explicitly executed the job, and I could correlate my message.
In my understanding, it should work, and the active token should continue till the end, but in fact, what is happening is that my process still waits at my Receive Task.

May I have missed something?

Updated unit test is here , but let me paste what really matters:

//	 Completing the job explicitly
	 Job receiveTaskJob = job(jobQuery().messages().executable().activityId("CompleteReceiveTaskTask"), processInstance);
//	  1st Approach

Here are some useful links for the ones who may face similar issues in the future: