Correlated Message throw does not trigger parent process

Hi

I am trying to correlate a message from a child process that is triggered by a call activity. This child process throws a message. But for some reason, the parent process is not able to catch the message.

I am getting the following error Cannot correlate message 'work': No process definition or execution matches the parameters

The child process throws a message event like this:
${execution.getProcessEngineServices().getRuntimeService().createMessageCorrelation("work").processInstanceId(execution.getVariable("parentProcessInstanceId")).setVariable("crqId", "myid").correlate()}

Child process:

Parent process:

Can someone please help me with this? Thanks!

MessageCatch.bpmn (5.8 KB) MessageThrow.bpmn (2.8 KB)

There are a few problems you’ve got. The first is the fact the parent process needs to be waiting at an active message receive event. Which it is not. While the Call Activity is still running the child process it will not move to the message event (as a side note you can remove the event based gateway if there is only one event)

If you want to wait for a message while the sub process is running. use a message boundary event
image

The call your making for messages is not quite right.

Don’t use the process instance id when correlating instead use a business key that you can pass to the sub process.

execution.getProcessEngineServices().getRuntimeService().createMessageCorrelation("work").processInstanceBusinessKey("somekey").correlate();

and finally - make sure you have a transaction boundry in your sub process before you send message. this will ensure the message is persisted to the DB before you try to correlate to it. best done by adding an asynchronous before tick box on your script task.

Thanks a lot @Niall That clears up most of the things for me.

Just one more thing. I am executing scenarios wherein I have 3 different messages that could be thrown from the child. Is it good practice

  1. Add 3 message boundary events to the call activity?

or

  1. Register the messages before executing the call activity in parallel flow?

I am trying to achieve something like below. Is this achievable in any way?

They should be attached to the Call Activity to ensure that the messages are only expected while the child process is running.
Otherwise,if the message is not fired you could get a deadlock