Message to reject multiple branches

Dear all,

I’m working with Camunda Platform 7, and I have the following process

the goal is to have parallel shortcut approval / rejections (like the logical “AND” behavior in many languages):

  • approval needs both branches to approve
  • if one rejects, the “shortcut” behavior is triggered via the boundary event that is identical for both branches, so it doesn’t need for the other branch to approve reject (since “FALSE AND X” is FALSE for any X).

The problem I have is that when I send the rejection message, I get the following error:
org.camunda.bpm.engine.MismatchingMessageCorrelationException: ENGINE-13031 Cannot correlate a message with name 'SignatureRejected' to a single execution. 2 executions match the correlation keys: CorrelationSet [businessKey=null, processInstanceId=null, processDefinitionId=null, correlationKeys=null, localCorrelationKeys=null, tenantId=null, isTenantIdSet=false, isExecutionsOnly=false]

I think this happens because I have two tokens that are travelling both branches in parallel, and both match with the message, but this is exactly what I want: I want both wait for approval tasks to react to the rejection and move forward.

What is the proper way to achieve the desired goal of “shortcut rejection”?

I think I have solved my issue by using correlateAll()

        // runtimeService.correlateMessage(firstMessage);
        runtimeService.createMessageCorrelation(firstMessage).correlateAll();
1 Like

You nailed the root-cause.

In the purest BPMN, a message can only be received by one receiver, so you would need to either put the parallel approves into a sub-process and have the sub-process itself listen for the message (UGLY), or do an event sub-process that is listening for the message (then only one is listening!) and set a variable when the message is received. You could then have conditional boundary events on the approval steps to do the actual short-circuit.

correlateAll is probably the cleanest, but it may have unintended side-effects… If you accidentally have multiple processes matching your conditions, and it wouldn’t error out - all the instances (not just the two branches) would match.

2 Likes