Camunda is unable to correlate messages Cannot correlate message: No process definition or execution matches the parameters'

I have simple two process definition which has a user task with listeners that correlates a message. We have a non-interrupting boundary event attached to them, which receives the message. I have two identical process definition; one is able to run while the other isn’t.
When looking through event-subscriptions REST-API, I am able to see the second process def (working one) creates a message receiver subscription and that goes away after the process is completed.

I get the following error when trying to start process instance:

Cannot instantiate process definition <id>: ENGINE-03051 There was an exception while invoking the TaskListener. Message: 'Unable to evaluate script while executing activity <id> in the process definition with id <id>: org.camunda.bpm.engine.MismatchingMessageCorrelationException: Cannot correlate message <id>: No process definition or execution matches the parameters' [ start-instance-error ]

Not working process def:

<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_1dn4t92" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.11.1" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.15.0">
  <bpmn:process id="sendExpNotification" name="sendExpNotification" isExecutable="true">
    <bpmn:startEvent id="mainStart">
      <bpmn:outgoing>start_user_task</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:sequenceFlow id="start_user_task" sourceRef="mainStart" targetRef="userTask" />
    <bpmn:userTask id="userTask" name="Task #1" camunda:assignee="Distanta">
      <bpmn:extensionElements>
        <camunda:taskListener event="assignment">
          <camunda:script scriptFormat="groovy">task.getExecution().getProcessEngineServices().getRuntimeService().createMessageCorrelation("sendEmail130").processInstanceId(task.getProcessInstanceId()).setVariable("taskId",task.getId()).setVariable("assignee","947adce5-2ae2-4877-8201-1bb6518da080").setVariable("heading","camunda test").setVariable("message","camunda test test").setVariable("icon","requirements").correlate();</camunda:script>
        </camunda:taskListener>
        <camunda:taskListener event="complete">
          <camunda:script scriptFormat="groovy">task.getExecution().getProcessEngineServices().getRuntimeService().createMessageCorrelation("sendEmail130").processInstanceId(task.getProcessInstanceId()).setVariable("taskId",task.getId()).setVariable("assignee","947adce5-2ae2-4877-8201-1bb6518da080").setVariable("heading","camunda test").setVariable("message","camunda test test").setVariable("icon","requirements").correlate();</camunda:script>
        </camunda:taskListener>
      </bpmn:extensionElements>
      <bpmn:incoming>start_user_task</bpmn:incoming>
      <bpmn:outgoing>user_task_end</bpmn:outgoing>
    </bpmn:userTask>
    <bpmn:endEvent id="branch_end">
      <bpmn:incoming>service_end</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="boundary_service" sourceRef="messageBoundry" targetRef="service" />
    <bpmn:boundaryEvent id="messageBoundry" cancelActivity="false" attachedToRef="userTask">
      <bpmn:outgoing>boundary_service</bpmn:outgoing>
      <bpmn:messageEventDefinition id="MessageEventDefinition_0en192e" messageRef="Message_0fc2f1r" />
    </bpmn:boundaryEvent>
    <bpmn:sequenceFlow id="user_task_end" sourceRef="userTask" targetRef="mainEnd" />
    <bpmn:endEvent id="mainEnd">
      <bpmn:incoming>user_task_end</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="service_end" sourceRef="service" targetRef="branch_end" />
    <bpmn:serviceTask id="service" name="sendExpreienceNotification" camunda:type="external" camunda:topic="maestro-experience-notification">
      <bpmn:extensionElements>
        <camunda:inputOutput>
          <camunda:inputParameter name="icon">${icon}</camunda:inputParameter>
          <camunda:inputParameter name="message">${message}</camunda:inputParameter>
          <camunda:inputParameter name="taskId">${taskId}</camunda:inputParameter>
          <camunda:inputParameter name="heading">${heading}</camunda:inputParameter>
          <camunda:inputParameter name="assignee">${assignee}</camunda:inputParameter>
        </camunda:inputOutput>
      </bpmn:extensionElements>
      <bpmn:incoming>boundary_service</bpmn:incoming>
      <bpmn:outgoing>service_end</bpmn:outgoing>
    </bpmn:serviceTask>
  </bpmn:process>
  <bpmn:message id="Message_0fc2f1r" name="sendEmail130" />
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="sendExpNotification">
      <bpmndi:BPMNEdge id="Flow_1cga36h_di" bpmnElement="service_end">
        <di:waypoint x="370" y="270" />
        <di:waypoint x="592" y="270" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_03aul94_di" bpmnElement="user_task_end">
        <di:waypoint x="390" y="117" />
        <di:waypoint x="592" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_13xfc42_di" bpmnElement="boundary_service">
        <di:waypoint x="320" y="175" />
        <di:waypoint x="320" y="230" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_02jvlga_di" bpmnElement="start_user_task">
        <di:waypoint x="215" y="117" />
        <di:waypoint x="290" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="mainStart">
        <dc:Bounds x="179" y="99" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_0yegqsq_di" bpmnElement="userTask">
        <dc:Bounds x="290" y="77" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_00q3joz_di" bpmnElement="branch_end">
        <dc:Bounds x="592" y="252" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_0tqg0fg_di" bpmnElement="mainEnd">
        <dc:Bounds x="592" y="99" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_0yvzvw6_di" bpmnElement="service">
        <dc:Bounds x="270" y="230" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_14m5xrt_di" bpmnElement="messageBoundry">
        <dc:Bounds x="302" y="139" width="36" height="36" />
      </bpmndi:BPMNShape>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

Working process def:

<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_1dn4t92" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.11.1" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.15.0">
  <bpmn:process id="boundaryEventAssignmentTaskTrigger" name="Boundary Event Assignment Task Trigger" isExecutable="true">
    <bpmn:startEvent id="StartEvent_1">
      <bpmn:outgoing>Flow_02jvlga</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:sequenceFlow id="Flow_02jvlga" sourceRef="StartEvent_1" targetRef="Activity_0yegqsq" />
    <bpmn:userTask id="Activity_0yegqsq" name="Task #1">
      <bpmn:extensionElements>
        <camunda:taskListener event="assignment">
          <camunda:script scriptFormat="groovy">task.getExecution().getProcessEngineServices().getRuntimeService().createMessageCorrelation("sendEmail145").processInstanceId(task.getProcessInstanceId()).setVariable("taskId",task.getId()).setVariable("assignee","947adce5-2ae2-4877-8201-1bb6518da080").setVariable("heading","camunda test").setVariable("message","camunda test test").setVariable("icon","requirements").correlate();</camunda:script>
        </camunda:taskListener>
        <camunda:taskListener event="complete">
          <camunda:script scriptFormat="groovy">task.getExecution().getProcessEngineServices().getRuntimeService().createMessageCorrelation("sendEmail145").processInstanceId(task.getProcessInstanceId()).setVariable("taskId",task.getId()).setVariable("assignee","947adce5-2ae2-4877-8201-1bb6518da080").setVariable("heading","camunda test").setVariable("message","camunda test test").setVariable("icon","requirements").correlate();</camunda:script>
        </camunda:taskListener>
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_02jvlga</bpmn:incoming>
      <bpmn:outgoing>Flow_03aul94</bpmn:outgoing>
    </bpmn:userTask>
    <bpmn:endEvent id="Event_00q3joz">
      <bpmn:incoming>Flow_1cga36h</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="Flow_13xfc42" sourceRef="Event_14m5xrt" targetRef="Activity_0x0axpg" />
    <bpmn:boundaryEvent id="Event_14m5xrt" cancelActivity="false" attachedToRef="Activity_0yegqsq">
      <bpmn:outgoing>Flow_13xfc42</bpmn:outgoing>
      <bpmn:messageEventDefinition id="MessageEventDefinition_0en192e" messageRef="Message_0fc2f1r" />
    </bpmn:boundaryEvent>
    <bpmn:sequenceFlow id="Flow_03aul94" sourceRef="Activity_0yegqsq" targetRef="Event_0tqg0fg" />
    <bpmn:endEvent id="Event_0tqg0fg">
      <bpmn:incoming>Flow_03aul94</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="Flow_1cga36h" sourceRef="Activity_0x0axpg" targetRef="Event_00q3joz" />
    <bpmn:serviceTask id="Activity_0x0axpg" name="Task #2" camunda:type="external" camunda:topic="maestro-experience-notification">
      <bpmn:extensionElements>
        <camunda:inputOutput>
          <camunda:inputParameter name="icon">${icon}</camunda:inputParameter>
          <camunda:inputParameter name="message">${message}</camunda:inputParameter>
          <camunda:inputParameter name="heading">${heading}</camunda:inputParameter>
          <camunda:inputParameter name="taskId">${taskId}</camunda:inputParameter>
          <camunda:inputParameter name="assignee">${assignee}</camunda:inputParameter>
        </camunda:inputOutput>
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_13xfc42</bpmn:incoming>
      <bpmn:outgoing>Flow_1cga36h</bpmn:outgoing>
    </bpmn:serviceTask>
  </bpmn:process>
  <bpmn:message id="Message_0fc2f1r" name="sendEmail145" />
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="boundaryEventAssignmentTaskTrigger">
      <bpmndi:BPMNEdge id="Flow_1cga36h_di" bpmnElement="Flow_1cga36h">
        <di:waypoint x="370" y="270" />
        <di:waypoint x="592" y="270" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_03aul94_di" bpmnElement="Flow_03aul94">
        <di:waypoint x="390" y="117" />
        <di:waypoint x="592" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_13xfc42_di" bpmnElement="Flow_13xfc42">
        <di:waypoint x="320" y="175" />
        <di:waypoint x="320" y="230" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_02jvlga_di" bpmnElement="Flow_02jvlga">
        <di:waypoint x="215" y="117" />
        <di:waypoint x="290" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
        <dc:Bounds x="179" y="99" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_0yegqsq_di" bpmnElement="Activity_0yegqsq">
        <dc:Bounds x="290" y="77" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_00q3joz_di" bpmnElement="Event_00q3joz">
        <dc:Bounds x="592" y="252" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_0tqg0fg_di" bpmnElement="Event_0tqg0fg">
        <dc:Bounds x="592" y="99" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_181d9l4_di" bpmnElement="Activity_0x0axpg">
        <dc:Bounds x="270" y="230" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_14m5xrt_di" bpmnElement="Event_14m5xrt">
        <dc:Bounds x="302" y="139" width="36" height="36" />
      </bpmndi:BPMNShape>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

Hello @dojha ,

the problem could be that in your first process, you have an assignment defined which would trigger the assignment event and try to correlate a message before the end of the transaction is reached. This would lead to the inspected behaviour.

The workaround could be to set the initial assignee using a “create” listener instead of the assignee field.

The reason why this would not work out-of-the-box is that message correlation of a process to itself is forbidden in BPMN and therefore not a default use case. Also, message correlation from a task listener sounds interesting. What is the concrete use case?

I hope this helps

Jonathan

1 Like

Hi @jonathan.lukas ,

Thanks, yep, it doesn’t work with create and pre-assigned script as the receiver wouldn’t have been registered. Also, the workaround you mentioned doesn’t work, same problem.

The use-case is to send notification based on the life cycle of a user task. I could probably do it straight through Java or some script but because of other constraints we need to do it through a Node-service (reason why we want to kickoff external service task). So basically, I want to fire off an external service task (has to be same process) from user tasks listeners.

Is there a more established way of doing it?

Hello @dojha ,

if you prefer an external task as implementation, I would recommend to use a separate process. This would work without limitations from missing subscriptions.

This process could then be started with a normal start event or the message start event, I guess this depends on your flavour.

One thing to consider with this approach is that there will be many process instances. Limiting the history time to live (advanced: or maybe customising it) is extremely important.

If this notification process can serve globally (for all user tasks in all processes), you might want to register task listeners programmatically by using a BpmnParseListener. This can be registered to the process engine with a plugin. If you need more input, I can help you. But you will also find examples on this, as this is a common approach.

Alternatively, you can use the spring event bridge or the j2ee event bridge (if you are deploying embedded as spring-boot, as camunda run or on wildfly). If you are interested, I can elaborate further on this.

I hope this helps

Jonathan

Hi @jonathan.lukas

I think pre-deploying this subprocess/process isn’t the ideal solution for my requirement. Ideally, it would be better if I could have everything a process needs inside a process definition. I don’t suppose I could use any other events too, right? Seems to me they behave similarly to the message event on this side.

Now I am thinking if I could add an activity which would do nothing but would add a message receiver after the process start (doesn’t work). Just a thought…as message boundary event creates message subscription which lasts until the process stops.

Can you elaborate on the alternative you mentioned?

Hello @dojha ,

if you want the notification process inside your process, you can add it as event-subprocess.

This is an event subscription on process level, just like you described.

Why would pre-deploying another process not be ideal? You could package it with your plugin and deploy it as soon as the process engine is initiated.

I hope this helps

Jonathan

@jonathan.lukas
I have tried the event subprocess route too. It behaves similarly and is not able to register receive message subscription before assignment (with pre-assigned assignee) and create listeners are fired.

Pre-deploying wouldn’t be ideal because it just increases the complexity and overhead when deploying to new environments for whoever is doing it.

btw, here’s the sub-process way I am trying:

<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_1byp8ae" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.11.1" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.15.0">
  <bpmn:process id="externalTaskListener" isExecutable="true">
    <bpmn:startEvent id="StartEvent_1">
      <bpmn:outgoing>Flow_0sbed0x</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:sequenceFlow id="Flow_0sbed0x" sourceRef="StartEvent_1" targetRef="Activity_1bbooym" />
    <bpmn:endEvent id="Event_0nqhzjs">
      <bpmn:incoming>Flow_04lsnl9</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:subProcess id="Activity_0knx4io" camunda:asyncBefore="true" camunda:asyncAfter="true" camunda:exclusive="false" triggeredByEvent="true">
      <bpmn:sequenceFlow id="Flow_03djl5r" sourceRef="Event_13fxky1" targetRef="Activity_1cae95b" />
      <bpmn:endEvent id="Event_1f67k18">
        <bpmn:incoming>Flow_03ww7pj</bpmn:incoming>
      </bpmn:endEvent>
      <bpmn:sequenceFlow id="Flow_03ww7pj" sourceRef="Activity_1cae95b" targetRef="Event_1f67k18" />
      <bpmn:userTask id="Activity_1cae95b" name="sub process task" camunda:assignee="Distanta">
        <bpmn:incoming>Flow_03djl5r</bpmn:incoming>
        <bpmn:outgoing>Flow_03ww7pj</bpmn:outgoing>
      </bpmn:userTask>
      <bpmn:startEvent id="Event_13fxky1" camunda:asyncBefore="true" camunda:asyncAfter="true" camunda:exclusive="false" isInterrupting="false">
        <bpmn:outgoing>Flow_03djl5r</bpmn:outgoing>
        <bpmn:messageEventDefinition id="MessageEventDefinition_1nl1mhw" messageRef="Message_0mxc9kd" />
      </bpmn:startEvent>
    </bpmn:subProcess>
    <bpmn:userTask id="Activity_1bbooym" name="Task with listener">
      <bpmn:extensionElements>
        <camunda:taskListener event="create">
          <camunda:script scriptFormat="groovy">task.getExecution().getProcessEngineServices().getRuntimeService().createMessageCorrelation("sendEmail145").processInstanceId(task.getProcessInstanceId()).setVariable("taskId",task.getId()).setVariable("assignee","947adce5-2ae2-4877-8201-1bb6518da080").setVariable("heading","camunda test").setVariable("message","camunda test test").setVariable("icon","requirements").correlate();</camunda:script>
        </camunda:taskListener>
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_0sbed0x</bpmn:incoming>
      <bpmn:outgoing>Flow_04lsnl9</bpmn:outgoing>
    </bpmn:userTask>
    <bpmn:sequenceFlow id="Flow_04lsnl9" sourceRef="Activity_1bbooym" targetRef="Event_0nqhzjs" />
  </bpmn:process>
  <bpmn:message id="Message_0mxc9kd" name="sendEmail145" />
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="externalTaskListener">
      <bpmndi:BPMNEdge id="Flow_0sbed0x_di" bpmnElement="Flow_0sbed0x">
        <di:waypoint x="188" y="117" />
        <di:waypoint x="240" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_04lsnl9_di" bpmnElement="Flow_04lsnl9">
        <di:waypoint x="340" y="117" />
        <di:waypoint x="392" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
        <dc:Bounds x="152" y="99" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_0nqhzjs_di" bpmnElement="Event_0nqhzjs">
        <dc:Bounds x="392" y="99" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_0avfgsd_di" bpmnElement="Activity_1bbooym">
        <dc:Bounds x="240" y="77" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_1k9oky7_di" bpmnElement="Activity_0knx4io" isExpanded="true">
        <dc:Bounds x="390" y="310" width="350" height="200" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="Flow_03djl5r_di" bpmnElement="Flow_03djl5r">
        <di:waypoint x="466" y="410" />
        <di:waypoint x="520" y="410" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_03ww7pj_di" bpmnElement="Flow_03ww7pj">
        <di:waypoint x="620" y="410" />
        <di:waypoint x="682" y="410" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="Event_1f67k18_di" bpmnElement="Event_1f67k18">
        <dc:Bounds x="682" y="392" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_1ecai6t_di" bpmnElement="Activity_1cae95b">
        <dc:Bounds x="520" y="370" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_1k9x1y8_di" bpmnElement="Event_13fxky1">
        <dc:Bounds x="430" y="392" width="36" height="36" />
      </bpmndi:BPMNShape>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

Hello @dojha ,

to make this work, just put an async after on the start event of the main process.

Jonathan

@jonathan.lukas thanks, it works but I will need look into what async after does.

1 Like

Hello @dojha ,

the reason why this works can be found here:

Jonathan

2 Likes

thanks a lot.

1 Like