Not able to receive message inside the pool

I have created a buyer seller model like below

I was able to start the buyer process using the process id

ProcessInstanceEvent workflowInstanceEvent = client
.newCreateInstanceCommand()
.bpmnProcessId(“Process_d392d363-2c0f-4449-a387-f740afec3094”)
.latestVersion()
.variables(Map.of(“message_content”, value))
.send()
.join();

but I m not able to find a way to receive the message which is published in the order-create send task, used below code for publishing the message

HashMap<String, Object> variables = new HashMap<>();
variables.put(“resultValue1”, job.getVariablesAsMap().get(“message_content”));
client.newPublishMessageCommand() //
.messageName(“order-receive”)
.correlationKey(“orderId”)
.variables(variables)
.send().join();

how can i receive this message on the order-receive message start event, do I need to start a new process instance for the seller pool, ? I had also tried the same using the bpmnProcessId of the seller pool, but it didnt worked I got the following error then

processing failed; nested exception is io.camunda.zeebe.client.api.command.ClientStatusException: Command ‘CREATE’ rejected with code ‘INVALID_STATE’: Expected to create instance of process with none start event, but there is no such event] with root cause

I m using spring-zeebe-starter client of version 8.0.7 with Zeebe 8.0 cluster

Hi,

When using a message start event leave the correlation key blank ("").
Furthermore, make sure that messageName in your publishMessageCommand is the same as specified in your BPMN process model. If both conditions hold, the buyer process should instantiate your seller’s process.

Thank you Stephan, I will check the same, can you please tell me whether I need to start the seller pool as a seperate process instance?

Each process/pool should be contained in a separate model.
It is not necessary to start the seller process explicitly - this is done automatically when the message event is received.

It worked when I gave CorrelationKey as empty, I had modified the flow as below

But now the problem is order-accepted service worker is called twice for each message publish from order-create . I am not sure why iam getting the message twice for each flow instance.

quite strange that only order-accepted service worker is behaving abnormally, the order-hold and oder-update service tasks are getting called correctly based on the conditions. Please see the below code for the order-accepted service worker

@ZeebeWorker(type = “order-accepted”, autoComplete = true)
public void orderAccepted(final ActivatedJob job, @ZeebeVariable Integer resultValue1) {
System.out.println(
"Order accepted message data from the process variables: "
+ resultValue1);
}

sometimes this will call twice, some times this wont even called, but the other order-update and order-hold will be called correctly.

Can we see the order-create worker? Maybe it is creating two messages?

Are you logging out in there to see if this is the case?

Please see below this is the workflow start code

@GetMapping("/start/{value}")
public String startWorkflowInstance(@PathVariable Integer value) {
ProcessInstanceEvent workflowInstanceEvent = client
.newCreateInstanceCommand()
.bpmnProcessId(“Process_d392d363-2c0f-4449-a387-f740afec3094”)
.latestVersion()
.variables(Map.of(“message_content”, value))
.send()
.join();
return workflowInstanceEvent.toString();
}

this is my order create service worker code

@ZeebeWorker(type = “order-create”, autoComplete = true)
public void orchestrateSomething(final ActivatedJob job) throws UnsupportedEncodingException {
System.out.println(
“Recieved data from the process variables: "
+ job.getVariables());
HashMap<String, Object> variables = new HashMap<>();
variables.put(“resultValue1”, job.getVariablesAsMap().get(“message_content”));
client.newPublishMessageCommand() //
.messageName(“order-receive”)
.correlationKey(”")
.variables(variables)
.send().join();
}

some times the order-accepted will be called twice, sometimes it wont even work.

Sorry, I can’t see anything obvious here.

If you put a complete reproducer in GitHub, I could run it and see if I can get the same issue and debug it.

I have uploaded the application to the github please see the link below

also the bpmn xml file is in the resources folder.