Search code examples
bpmncamunda

Camunda - Intermedia message event cannot correlate to a single execution


I created a small application (Spring Boot and camunda) to process an order process. The Order-Service receives the new order via Rest and calls the Start Event of the BPMN Order workflow. The order process contains two asynchronous JMS calls (Customer check and Warehouse Stock check). If both checks return the order process should continue.

The Start event is called within a Spring Rest Controller:

     ProcessInstance processInstance =
             runtimeService.startProcessInstanceByKey("orderService", String.valueOf(order.getId()));

The Send Task (e.g. the customer check) sends the JMS message into a asynchronous queue. The answer of this service is catched by a another Spring component which then trys to send an intermediate message:

     runtimeService.createMessageCorrelation("msgReceiveCheckCustomerCredibility")
             .processInstanceBusinessKey(response.getOrder().getBpmnBusinessKey())
             .setVariable("resultOrderCheckCustomterCredibility", response)
             .correlate();

I deactivated the warehouse service to see if the order process waits for the arrival of the second call, but instead I get this exception:

  1115 06:33:08.564 WARN  [o.c.b.e.jobexecutor] ENGINE-14006 Exception while executing job  67d2cc24-0769-11ea-933a-d89ef3425300: 
  org.springframework.messaging.MessageHandlingException: nested exception is org.camunda.bpm.engine.MismatchingMessageCorrelationException: ENGINE-13031 Cannot correlate a message with name 'msgReceiveCheckCustomerCredibility' to a single execution. 4 executions match the correlation keys: CorrelationSet [businessKey=1, processInstanceId=null, processDefinitionId=null, correlationKeys=null, localCorrelationKeys=null, tenantId=null, isTenantIdSet=false]

This is my process. I cannot see a way to post my bpmn file :-( enter image description here

What can't it not correlate with the message name and the business key? The JMS queues are empty, there are other messages with the same businessKey waiting.

Thanks!


Solution

  • Just to narrow the problem: Do a runtimeService eventSubscription query before you try to correlate and check what subscriptions are actually waiting .. maybe you have a duplicate message name? Maybe you (accidentally) have another instance of the same process running? Once you identified the subscriptions, you could just notify the execution directly without using the correlation builder ...