@Niall I am trying to correlate a message but I have a lot of messages and every message is connected to the login user.
So the user can run only a particular message but not all messages that are waiting to be executed.
So my message name looks like that: myHome-${execution.processBusinessKey}
org.camunda.bpm.engine.MismatchingMessageCorrelationException: Cannot correlate message ‘myHome-20210407378941000000001’: No process definition matches the parameters
Hi @Niall I found solution that worked for me. I didnt understand why the normal solution above did not work… hope that this example will help other people with similar issue.
EventSubscription eventSubscription = runtimeService.createEventSubscriptionQuery().eventName("myHome-"+ order.get().getId()).eventType("message").singleResult();
if (eventSubscription == null) {
String errorMessage = String.format("Message event subscription for businessKey %s named %s does not exist", order.get().getId(), "amyHome-"+ order.get().getId());
throw new InvalidRequestException(Response.Status.NOT_FOUND, errorMessage);
}
Execution messageExecution = runtimeService.createExecutionQuery().executionId(eventSubscription.getExecutionId()).singleResult();
Map<String, Object> variables = new HashMap<>();
variables.put("variableName1", choice.getHome());
variables.put("variableName2", choice.getHotel());
runtimeService.messageEventReceived(eventSubscription.getEventName(), messageExecution.getId(), variables);