Same message event, two processes

Hi
I am trying to implement two different processes like in the attached picture below.
The first process has as a start event the OnlineOrderReceived message and the second one PaperOrderReceived message. Both of the orders will need to be checked in the UI which afterwards will send an event OrderChecked.processes

These are two separate processes deployed on the same Camunda instance. Apache Kafka is used to send the messages.

How should I handle the correlation in order for both processes to receive and handle the OrderChecked event correctly?

This is the current solution which fails (it is correlating correctly the instances of process 1 but fails when trying to correlate instances of process 2.

camunda.getRuntimeService().createMessageCorrelation("OrderChecked")
                .processInstanceBusinessKey(order.getId())
                .setVariable("order", order)
                .correlateWithResult();

The error is: org.camunda.bpm.engine.MismatchingMessageCorrelationException: Cannot correlate message ‘OrderChecked’: No process definition or execution matches the parameters

Thank you for helping

can you upload the model?

Thank you for the reply. Here are the models. offline.bpmn (3.6 KB) online.bpmn (3.6 KB)

They’re both the same model, can you upload the “offline” model?

Hmm, sorry here it isoffline.bpmn (3.6 KB)

What call do you use to start these processes?
Do they have different business keys?

The first one is listening to OnlineOrderReceived and the second one to PaperOrderReceived. The business key is the order id.

camunda.getRuntimeService().createMessageCorrelation(message.getMessageType())
                .processInstanceBusinessKey(order.getId().toString())
                .setVariable("order", order)
                .correlateWithResult();

Sorry - just to clarify - are you trying to trigger both message events with the same call?

We have defined another flow that handles the import of orders into our system. At the end of this import flow a different message is sent based on the order type, either OnlineOrderReceived or PaperOrderReceived. After the orders are “catched” in their flow we wait for another message that is triggered from a UI application. They are sending the OrderChecked via Kafka. They can only send us the order id for correlation purposes.

So it seems to be that the models should work perfectly fine. The error messages suggests that the most likely problem is that either:

  • The process you’re sending the message to doesn’t yet have a token waiting at the message event
  • The process you’re sending the message to doesn’t have the business key you’re expecting it to have.

Can you confirm this?

I have just created this right now. As you can see we have a token waiting at the message event in each flow

When I send the OrderChecked event with business key 51 the process continues normally.
But when I send the OrderChecked event with business key 52 it fails with

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

I tried to replicate the problem with the models you send me but I wasn’t able to. I was able to trigger both messages without any issues. What is happening does seem really strange but i’m not sure what could be causing it.

Indeed, it is strange. So is it correct two processes can listen for the same message without interfering with each other? Can we maybe try to correlate the messages differently?

Ok, so I cleared the database, redeployed the projects and now everything is working fine. Thank you again for you time!