Throwing message event at specific subprocess of other multiinstance subprocess of master process

Hi there,

I am wondering what is the recommended way of throwing a message event at a subprocess instance which is a subprocess of a multiinstance subprocess of a master process as illustrated by my attachment:

The master process has a variable called ID1 and the multiinstance subprocess instance has a local variable called ID2. How can I throw the message event to the proper execution, using method runtimeService.messageEventReceived(correlationMessage, execution.getId(), processVariables)? The “proper execution” would be one identified by a specific value of ID2.

Or should I rather use RuntimeService.correlateMessage(String messageName, Map<String,Object> correlationKeys, Map<String,Object> processVariables) method?

I have taken both approaches, but no luck. Any other suggestions, please?

Thank you.

Cristian

Hallo Cristian,

I think you should try following

// correlate the message runtimeService.createMessageCorrelation("messageName") .processInstanceBusinessKey("AB-123") .setVariable("payment_type", "creditCard") .correlate();

you can read more about the topic here https://docs.camunda.org/manual/7.5/reference/bpmn20/events/message-events/

Hope that helps,
Askar

Thank you, Askar. I have solved it already. I used i/o parameter mapping to pass a triple of values and then I queried by those three and got a unique execution id.

Hi,

I want to achieve the following functionality:
https://cawemo.com/share/c06bf4fa-a681-4899-9f0d-17d732fe5afa

Do you think it will work to send/received messages from/to within a multi instance subprocess into an event subprocess?

Thx