In my project, i use camunda with the following setup :
spring-boot : 2.3.0.RELEASE
camunda : 7.12.0
camunda-bpm-assert : 5.0.0
In my bpmn multiple_instance.bpmn (see above), a parallel multiple instance subprocess is used.
A collection is declared with an element variable (for mapping) - no loop cardinality is used.
I’m not able to correlate a message with an instance of this subprocess. The error thrown by camunda looks like :
ENGINE-13031 Cannot correlate a message with name ‘X’ to a single execution. Y executions match the correlation keys
Here are two reproducers. The collection (items) used by the multiple instance subprocess is given at a process instance creation. Then, we try to correlate with an item of the collection.
In my project, camunda is embedded in a spring boot rest service.
“Production” code is quite similar than the code provided in my reproducers.
It looks like
@Service
public class CamundaService {
private ProcessEngine processEngine;
public void executeCorrelation(
String eventMessage, String businessKey, String correlationKey, String correlationValue) {
Map<String, Object> correlationKeys = new HashMap<>();
correlationKeysMap.put(correlationKey, correlationValue);
processEngine
.getRuntimeService()
.correlateMessage(
eventMessage,
businessKey,
correlationKeys ,
null
);
}
}
It seems that camunda ignores correlationKeys => if there are more than on subprocess instance, camunda throws the error i gave in my first message (it works if there is only one subprocess instance).
java.lang.AssertionError: Expecting ProcessInstance {id=‘9’, processDefinitionId=‘multiplie_instance_problem:2:7’, businessKey=‘businessKey’} to be waiting at [bad_event_id], but it is actually waiting at [event_for_subprocess, event_for_subprocess, event_for_subprocess].
As expected, we see that three instances are waiting to be correlated.
I’ve just noticed that you’re creating the list variable as “local” when you create the instance. It should be a regular variable.
The variables become local per instance of the list. not the list itself, so try that and see how it goes
Here is a sample spring boot maven projet reproducing the problem : github project
A REST webservice with camunda embedded/h2 database is available.
Two junit classes (one doing REST calls, the other using BpmnAwareTests) are also available to reproduce the problem.
I don’t understand why i can’t correlate a specific subprocess instance.
The problem also exists with a sequential multiple instances subprocess.