Cannot correlate message when inside Event subprocess

Hello,

I have this diagram.

I am using the generic error handling pattern described here:

I also have another Event subprocess called “Cancel Subprocess” that should be triggered when receiving “CANCEL” message.

In my case, Step 1 or Step 2 can throw BPMN Error called “review” which I am catching in Event Subprocess called “Review subprocess”.

When I am inside the Review Subprocess, any CANCEL message I try to correlate by calling /message gives me error.
org.camunda.bpm.engine.MismatchingMessageCorrelationException: Cannot correlate message ‘CANCEL_MESSAGE’: No process definition or execution matches the parameters

Another problem is when Review completes and I either retry or continue to the task where I left off in the main process, and then I try to correlate the CANCEL message, I get above error as well.

How can I make sure that no matter where the execution is at, CANCEL message is always received and cancels any task that is in progress either in main process or in any event sub processs?

Regards,
Yogesh

Hi @yogeshrnaik,

I haven’t tried it by myself, but you can try to add a copy of the cancel event subprocess into the error handling event subprocess as well.

Hope this helps, Ingo

Yes @Ingo_Richtsmeier, adding Copy of Cancel process inside the Review event sub process works but I don’t want to duplicate the Cancel process everywhere. I am planning to add other Event subprocesses and there also I will have to copy Cancel process for this to work. Is there any other way to make it work?

Also, as mentioned in original description above: another problem is when after Review I resume the Main process then the Cancel message correlation stops working for Main process. Is this a bug?

Hi @yogeshrnaik,

an event subprocess listens to events that happens in the scope of the super process. If you catch the error event, the process will leave this scope and can’t listen to the other event (cancel) anymore.

Thats how BPMN 2.0 is specified.

Niall uses the process instance modification (Process Instance Modification | docs.camunda.org) to return back into the super process.

But this is dangerous, as the docs say:

Modification of the own process instance
Process instance modification within the same instance is not recommended! An activity which tries to modify its own process instance can cause undefined behavior, which should be avoided.

Maybe you have touched an edge case, that Niall hadn’t had in this mind.

Another option could be to catch a non-interrupting event first and cascade to an interrupting event in the event subprocess. Start with an noninterrupting escalation event and emit the error after the review.

Errors in BPMN are always interrupting and only avaiable as end event.

Hope this helps, Ingo

@Ingo_Richtsmeier
Can you please elaborate this with an example? You can use the BPMN diagram I have added in my original question.
If I understand correctly, you are suggesting to add a non-interrupting event to STEP_1 and also to STEP_2 in my diagram. And then how do I cascade it to an interrupting event in the event subprocess?
If STEP_1 and STEP_2 are Service tasks with JavaDelegate, how do I raise Escalate event from the JavaDelegate class?