Use of Message Correlation with Message start event in Camunda 8

Hi Team,
I am trying to correlate message through message correlation and I am trying to use it with Message start event. When I am using below code snippet, its correlating with only 1 field of the variable json of operate set from our java code, irrespective of what I am passing in Correlation Key in BPMN:
publishMessageResponse = zeebeClient.newPublishMessageCommand()
// .messageName(messageName)
// .correlationKey(correlationKey)
// .send().exceptionally(throwable → {
// throw new ZeebeException(“Could not correlate instance for correlationKey {” + correlationKey + “}”, throwable);
// }).toCompletableFuture().get();

Also, even if correlation key doesnt match… still it passes the code successfully without any error.
Kindly suggest

Hi,

Think about a start event, it starts a new process instance and thus there is nothing to correlate to in the first place…

I typically see a message used for a start event, eg order received. Use an intermediate catch event to correlate to an existing process, eg order cancelled…

Regards

Rob

1 Like

Hello @Pratiksha1205 ,

@Webcyberrob is Right, In the message start event if the message with matching name is published it will trigger the instance

You can find more info about messsage start event here, reference video on how to trigger an intermediate message catch event

Hi Rob and Praveen, Thanks for the response.
Actually I am trying to do message correlation in an event subprocess and when I am trying to correlate based on process variables, which m setting at the start of the process instance and also we are passing this process variables while creating the new process instance, so its correlating with process variables. Also, our parent process is asynchronous.
But how can I correlate based on process instance Key.

Hi,

My suggestion is dont…

Rationale: its seems like you need a unique ID. The instance id is attractive, and I guess you coukd always extract the instance id and store it as a process variable and use correlation…

However, if you’re going to do this, why not generate your own guid as a variable and use that as the correlation key? From a security perspective this guid has limited meaning. If you expose the instance id, you are exposing an internal identifier to a potentially unknown external context…This identifier is enduring and thus could lead to further vulnerability…

Regards

Rob