cancel
Showing results for 
Search instead for 
Did you mean: 

Error boundary event on global scope

workflowuser2
Champ in-the-making
Champ in-the-making
hi,

I am looking into catching BpmnError from any of the Java Service Tasks in the process.
Currently, I am able to catch error within the "subprocess" scope using the following process definition:

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC" xmlnsSmiley Surprisedmgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <process id="SubprocessCompensation" name="process1">
    <startEvent id="startevent1" name="Start"></startEvent>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow1" name="" sourceRef="startevent1" targetRef="servicetaskMain1"></sequenceFlow>
    <sequenceFlow id="flow2" name="" sourceRef="servicetaskMain1" targetRef="subProcess"></sequenceFlow>
    <sequenceFlow id="flow3" name="" sourceRef="subProcess" targetRef="servicetaskMain2"></sequenceFlow>
    <sequenceFlow id="flow4" name="" sourceRef="servicetaskMain2" targetRef="endevent1"></sequenceFlow>
    <serviceTask id="servicetaskMain1" name="Service Task Main1" activiti:async="true" activiti:class="com.acme.delegates.Main1Delegate"></serviceTask>
    <serviceTask id="servicetaskMain2" name="Service Task Main2" activiti:async="true" activiti:class="com.acme.delegates.Main2Delegate"></serviceTask>
   
    <transaction id="myTransaction">
    <subProcess id="subProcess">
      <startEvent id="subProcessStart" />
      <sequenceFlow id="flow12" sourceRef="subProcessStart" targetRef="servicetask1" />
      <sequenceFlow id="flow13" sourceRef="servicetask1" targetRef="servicetask2" />
      <sequenceFlow id="flow17" sourceRef="servicetask2" targetRef="throwCompensation" />
      <sequenceFlow id="flow18" sourceRef="throwCompensation" targetRef="subProcessEnd" />
      <serviceTask id="servicetask1" name="Service Task 1" activiti:async="true" activiti:class="com.acme.delegates.Sub1Delegate"></serviceTask>
      <serviceTask id="undoTask1" isForCompensation="true" activiti:async="true" activiti:class="com.acme.delegates.UndoSub1Delegate" />
      <serviceTask id="servicetask2" name="Service Task2" activiti:async="true" activiti:class="com.acme.delegates.Sub2Delegate"></serviceTask>
      <serviceTask id="undoTask2" isForCompensation="true" activiti:async="true" activiti:class="com.acme.delegates.UndoSub2Delegate" />
      <endEvent id="subProcessEnd" />
      <boundaryEvent id="compensateTask1Evt" attachedToRef="servicetask1" >      
          <compensateEventDefinition />
      </boundaryEvent>
      <boundaryEvent id="compensateTask2Evt" attachedToRef="servicetask2" >      
          <compensateEventDefinition />
      </boundaryEvent>
      <intermediateThrowEvent id="throwCompensation">
        <compensateEventDefinition/>
      </intermediateThrowEvent>
      <association associationDirection="One" id="a1"  sourceRef="compensateTask1Evt" targetRef="undoTask1" />
      <association associationDirection="One" id="a2"  sourceRef="compensateTask2Evt" targetRef="undoTask2" />
    </subProcess>
    </transaction>
   
    <serviceTask id="servicetaskError1" name="Service Task Error1" activiti:async="true" activiti:class="com.acme.delegates.Main1Delegate"></serviceTask>
    <endEvent id="errorEnd" />
    <sequenceFlow id="flow_error1" sourceRef="boundaryerror1" targetRef="servicetaskError1" />
    <sequenceFlow id="flow_error2" sourceRef="servicetaskError1" targetRef="errorEnd" />
   
     <boundaryEvent id="boundaryerror1" attachedToRef="subProcess">
      <errorEventDefinition/>
   </boundaryEvent>
  </process>
</definitions>


How can I catch boundary event on the global scope (main process)?
     <boundaryEvent id="boundaryerror1" attachedToRef="???">
      <errorEventDefinition/>
   </boundaryEvent>


Thanks
2 REPLIES 2

frederikherema1
Star Contributor
Star Contributor
Activiti assumes a boundry-event is always attached (attachedToRef) to an activity-instance. So using the process-id as value for "attachedToRef" won't work.

I'm afraid the only workaround is to contain all of your activities (except of start and end-events) in a subprocess…

workflowuser2
Champ in-the-making
Champ in-the-making
Thanks frederikheremans.

Activiti assumes a boundry-event is always attached (attachedToRef) to an activity-instance. So using the process-id as value for "attachedToRef" won't work.

I'm afraid the only workaround is to contain all of your activities (except of start and end-events) in a subprocess…