BadUserRequestException

I am playing around multiple instances of camunda and I am facing Issue with the processing the message from rabbitMq. Below is the process diagram:
order.bpmn (8.5 KB)
My invoking of process looks like this:
camunda.getRuntimeService().createMessageCorrelation(ProcessConstants.MSG_NAME_GoodsShipped) //
.processDefinitionId(UUID.randomUUID().toString())
.processInstanceVariableEquals(ProcessConstants.VAR_NAME_orderId, orderId) //
.setVariable(ProcessConstants.VAR_NAME_shipmentId, shipmentId) //
.correlateWithResult();

The process works fine when there is only instance of camunda running. But when I am running multiple instances, I am facing the below exception:
org.camunda.bpm.engine.BadUserRequestException: ENGINE-13025 Cannot specify a process definition id when correlate a message, except for explicit correlation of a start message.

Hi @abhishekBharadwaj,

How does your application look like when you try the multiple instances?

Best regards,
Yana

Hi @Yana,

I am running the instances on different port numbers and I am able to login to all of the instances if thats what you are trying to know. I can see the cockpit tasks pages in all the instances. When I bring up 2 instances, I can see 4 instances of process running in both of the instances. Let me know if you need more information

Best Regards,
Abhishek

Hi @abhishekBharadwaj,

I wanted to say “process” and not “application”. Do you run the same process for multi instance?

Best regards,
Yana

Hi @Yana,

Thats correct. I am new to the tool. So am I doing it wrong?

Best Regards,
Abhishek

Hi @Yana,

I am referring to a sample project on GITHub. The link is: https://github.com/berndruecker/camunda-spring-boot-amqp-microservice-cloud-example
You can refer to this project if my information is not enough.

Best Regards,
Abhishek.

Hi @abhishekBharadwaj,

You can correlate by processDefinitionId only start messages, which is not your case in the provided diagram.

Best regards,
Yana

Hi @Yana,

Thanks for the help. I understood ans resolved this issue.
The problem was that all the instances were identical and hence the engine was ambiguous to assign the message to any of the instance. So to resolve this, I started process with a unique business key and when the inbound message came, I fetched instance based on business key and assigned it the message processing.

Best Regards,
Abhishek