Correlate message to waiting event subprocess within multi-instance subprocess

Hi @Niall,

Glad to see you’re active on these forums. I really enjoyed your introductory videos on Camunda.

My original attempt was actually the following:

engine.getRuntimeService()
    .createMessageCorrelation("ItemCanceledEvent")
    .processInstanceBusinessKey(sessionId)
    .localVariableEquals("item", item)
    .setVariable("someCancelationKey", someValue)
    .correlate();

but that results in a different error:

ENGINE-16004 Exception while closing command context: Cannot correlate message 'ItemCanceledEvent': No process definition or execution matches the parameters

FWIW, I have several other message receive tasks in the “real” model for which I had to explicitly set the element variable in the Input/Output mapping before it would correlate properly (as inspired by this comment).