Catching error boundary event from event subprocess

Hi,

I have the following (simplified) model:

<?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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_12we8qy" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.11.1" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.15.0">
  <bpmn:collaboration id="Collaboration_18831ch">
    <bpmn:participant id="Test_process" name="Test process" processRef="Test_process_" />
  </bpmn:collaboration>
  <bpmn:process id="Test_process_" name="Test process" isExecutable="true">
    <bpmn:laneSet id="LaneSet_1kggapc">
      <bpmn:lane id="AGV_lane" name="Operator">
        <bpmn:flowNodeRef>SE_NFT</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>DTA</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Event_1ntyjlz</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Event_0nk69wy</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Activity_0luu3xg</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Event_04ks1or</bpmn:flowNodeRef>
      </bpmn:lane>
    </bpmn:laneSet>
    <bpmn:sequenceFlow id="Flow_17n512c" sourceRef="DTA" targetRef="Event_1ntyjlz" />
    <bpmn:sequenceFlow id="Flow_0eg3yhw" sourceRef="Event_04ks1or" targetRef="Event_0nk69wy" />
    <bpmn:sequenceFlow id="Flow_0xvcybn" sourceRef="SE_NFT" targetRef="DTA" />
    <bpmn:startEvent id="SE_NFT" name="Main process started" camunda:asyncAfter="true">
      <bpmn:extensionElements>
        <camunda:executionListener event="end">
          <camunda:script scriptFormat="groovy">execution.setVariable("taskType", 0);
//execution.setVariable("FeedingTriggersQueue", []);</camunda:script>
        </camunda:executionListener>
        <camunda:formData>
          <camunda:formField id="tray_type" label="Tray type" type="string" defaultValue="A" />
          <camunda:formField id="LS" label="Loading station" type="string" defaultValue="LS2" />
          <camunda:formField id="target_loc" label="Target location" type="string" defaultValue="W1" />
        </camunda:formData>
      </bpmn:extensionElements>
      <bpmn:outgoing>Flow_0xvcybn</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:userTask id="DTA" name="Do Task A" camunda:assignee="demo">
      <bpmn:incoming>Flow_0xvcybn</bpmn:incoming>
      <bpmn:outgoing>Flow_17n512c</bpmn:outgoing>
    </bpmn:userTask>
    <bpmn:boundaryEvent id="Event_04ks1or" name="Faile task" camunda:asyncAfter="true" attachedToRef="DTA">
      <bpmn:outgoing>Flow_0eg3yhw</bpmn:outgoing>
      <bpmn:errorEventDefinition id="ErrorEventDefinition_0k9z4k6" errorRef="Error_1t91xtw" />
    </bpmn:boundaryEvent>
    <bpmn:subProcess id="Activity_0luu3xg" triggeredByEvent="true">
      <bpmn:sequenceFlow id="Flow_1pq2u5s" sourceRef="Event_10qd26b" targetRef="Event_1m8dryj" />
      <bpmn:startEvent id="Event_10qd26b" name="New message arrived" camunda:asyncAfter="true" isInterrupting="false">
        <bpmn:outgoing>Flow_1pq2u5s</bpmn:outgoing>
        <bpmn:messageEventDefinition id="MessageEventDefinition_032zzkh" messageRef="Message_0ll5rvu" />
      </bpmn:startEvent>
      <bpmn:endEvent id="Event_1m8dryj" name="Fail main task">
        <bpmn:incoming>Flow_1pq2u5s</bpmn:incoming>
        <bpmn:errorEventDefinition id="ErrorEventDefinition_1szes65" errorRef="Error_1t91xtw" />
      </bpmn:endEvent>
    </bpmn:subProcess>
    <bpmn:endEvent id="Event_1ntyjlz" name="Process finished">
      <bpmn:incoming>Flow_17n512c</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:endEvent id="Event_0nk69wy" name="Process failed">
      <bpmn:incoming>Flow_0eg3yhw</bpmn:incoming>
    </bpmn:endEvent>
  </bpmn:process>
  <bpmn:message id="Message_05l6ffu" name="feedingTriggerStartNew_msg" />
  <bpmn:message id="Message_0ll5rvu" name="feedingTrigger_msg" />
  <bpmn:error id="Error_1t91xtw" name="task_fail_msg" errorCode="task_fail_msg_code" />
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_18831ch">
      <bpmndi:BPMNShape id="Participant_1c9u4jt_di" bpmnElement="Test_process" isHorizontal="true">
        <dc:Bounds x="160" y="80" width="620" height="550" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Lane_04xa2hz_di" bpmnElement="AGV_lane" isHorizontal="true">
        <dc:Bounds x="190" y="80" width="590" height="550" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="Flow_0xvcybn_di" bpmnElement="Flow_0xvcybn">
        <di:waypoint x="338" y="190" />
        <di:waypoint x="470" y="190" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0eg3yhw_di" bpmnElement="Flow_0eg3yhw">
        <di:waypoint x="570" y="248" />
        <di:waypoint x="570" y="340" />
        <di:waypoint x="684" y="340" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_17n512c_di" bpmnElement="Flow_17n512c">
        <di:waypoint x="570" y="190" />
        <di:waypoint x="684" y="190" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="Event_0i32p7d_di" bpmnElement="SE_NFT">
        <dc:Bounds x="302" y="172" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="290" y="215" width="66" height="27" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_18g3rk8_di" bpmnElement="DTA">
        <dc:Bounds x="470" y="150" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_1l99q2g_di" bpmnElement="Activity_0luu3xg" isExpanded="true">
        <dc:Bounds x="280" y="440" width="340" height="140" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="Flow_1pq2u5s_di" bpmnElement="Flow_1pq2u5s">
        <di:waypoint x="356" y="500" />
        <di:waypoint x="552" y="500" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="Event_1wq0nfe_di" bpmnElement="Event_10qd26b">
        <dc:Bounds x="320" y="482" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="304" y="525" width="70" height="27" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_0ly7lzw_di" bpmnElement="Event_1m8dryj">
        <dc:Bounds x="552" y="482" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="536" y="525" width="69" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_1ntyjlz_di" bpmnElement="Event_1ntyjlz">
        <dc:Bounds x="684" y="172" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="662" y="215" width="81" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_0nk69wy_di" bpmnElement="Event_0nk69wy">
        <dc:Bounds x="684" y="322" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="668" y="365" width="70" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_1oeimey_di" bpmnElement="Event_04ks1or">
        <dc:Bounds x="552" y="212" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="596" y="246" width="48" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>


When the process is running and there’s a token in the User task, I assumed that the boundary error event is “active”.

Then during that time, a non-interrupting message event gives some information, there’s some flow happening which I skip for sake of brevity and at some point there’s an error through event, which should trigger the error boundary event.

But I get the following error:
“Execution with id ‘Event_1m8dryj’ throws an error event with errorCode ‘task_fail_msg_code’, but no catching boundary event was defined. Execution is ended.”

What do I do wrong?

Hi @kontrag,

The error is thrown outside the scope of “Do Task A” task, so the error boundary event attached to the task is not supposed to catch it.

error boundary event for short, catches errors that are thrown within the scope of the activity on which it is defined

1 Like

Hi @kontrag,

Something similar to the below model might serve your need.

Thanks for the answer @hassang .
Unfortunately, though, your solution will not work as the main process contains a lot of tasks (not only the Do Task A), so I cannot put it within a subprocess (so I could attach the boundary event there).

Will probably think to replace the error event with some conditional event but have to think more how are the conditions evaluated.

Or maybe, could I trigger the error boundary event with some code? e.g. if I know the task_instance_id?

Hi @kontrag,

Could you please elaborate more? Is the error supposed to get thrown from within the task?

The error is thrown on some specific cases upon arrival of an external message (see event subprocess).
When the error is thrown I want one specific task (in a series of tasks) to stop its execution and do something else.
It’s what I have modeled, omitting the rest part of the model for simplicity.

Hi @kontrag,

Then I believe you can simply replace the error boundary event with a message boundary event attached to the task and remove the event sub-process.

Thanks for the ideas @hassang .
Replacing the event sub-process is hard as it has some business logic behind (apart from “canceling” a user task).
At least I realized now that the error events should be within the right scope (which in my current model is not the case).
I will experiment with the conditional (boundary) events.

Hi @kontrag,

If extra logic needs to be run as part of the event sub-process then you can have a model similar to the attached simplified one.
example_process.bpmn (5.7 KB)

The same message name is used for both the boundary attached event and the non-interrupting message start event.

But when correlate is called, all attribute should be set to true