Activiti 5.22: Multiple (throw) end error event, one/ multiple (catch) start error events in Event-Subprocess

cancel
Showing results for 
Search instead for 
Did you mean: 
stanlyhamburg
Active Member

Activiti 5.22: Multiple (throw) end error event, one/ multiple (catch) start error events in Event-Subprocess

Cons. Activiti 5.22:

We have a cenralized error handling in Event Subprocess

for catching of errors throwed in end events (of top process).

1. Are multiple start error events (catch)  in Event-Subprocess allowed ?

2. if we use in Event-Subprocess onyl ONE catch error start with NO errorCode defined,

can it catch regardless different errors (and distinguish all errros) ?

Regards

Stanly

6 Replies
daisuke-yoshimo
Senior Member

Re: Activiti 5.22: Multiple (throw) end error event, one/ multiple (catch) start error events in Event-Subprocess

How about preparing an event subprocess for each error code?

daisuke-yoshimo
Senior Member

Re: Activiti 5.22: Multiple (throw) end error event, one/ multiple (catch) start error events in Event-Subprocess

> 2. if we use in Event-Subprocess onyl ONE catch error start with NO errorCode defined,

can it catch regardless different errors (and distinguish all errros) ?

If you are throwing an error via an error end event, you may be able to identify it from the activity ID of the end event(history).

Table ACT_HI_ACTINST

HistoryService.createHistoricActivityInstanceQuery()

HistoryService (Activiti - Engine 5.22.0 API) 

stanlyhamburg
Active Member

Re: Activiti 5.22: Multiple (throw) end error event, one/ multiple (catch) start error events in Event-Subprocess

Thank you, Daisuke !

Catching all BpmnErrors by Catch Error Event without errorCode is for us the best solution (at the moment).

Any ScriptTask in flow could have an technical/business error, but Error Handling (in our case) is the same.

We shell try  HistoryService.createHistoricActivityInstanceQuery() and feed back out expirience ...

Thanks a lot!

daisuke-yoshimo
Senior Member

Re: Activiti 5.22: Multiple (throw) end error event, one/ multiple (catch) start error events in Event-Subprocess

@stanlyhamburg

Your bpmn throw error from other than the end event, is not it?
Then, I can not solve it with my method.

How about set variable before throwing error?


For example, in the case of an error end event, you can set a variable with the execution listener at the start.

For script tasks, you can set a variable in the line before throwing error.

<?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:xsd="http://www.w3.org/2001/XMLSchema" 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/processdef">
<process id="process" isExecutable="true">
<startEvent id="sid-D22C5BB2-35E5-4703-8E85-AB30A3C3B229"></startEvent>
<subProcess id="sid-F0F655FC-61D4-46BA-8251-6BF554FF53F2" name="subProcess" triggeredByEvent="true">
<startEvent id="sid-1696D132-04C3-4AF3-A94C-EC986972FF63" name="erro1">
<errorEventDefinition></errorEventDefinition>
</startEvent>
<userTask id="test1" name="test1">
<extensionElements>
<activiti:formProperty id="errorCode" name="errorCode" type="string" variable="errorCode" writable="false"></activiti:formProperty>
</extensionElements>
</userTask>
<endEvent id="sid-9113B09B-C3BF-4192-8DED-8CF5A5E8E132"></endEvent>
<sequenceFlow id="sid-A476028E-9173-4989-8061-1D334A745B9E" sourceRef="sid-1696D132-04C3-4AF3-A94C-EC986972FF63" targetRef="test1"></sequenceFlow>
<sequenceFlow id="sid-126CBABD-B23C-4CA2-93D4-44B099929760" sourceRef="test1" targetRef="sid-9113B09B-C3BF-4192-8DED-8CF5A5E8E132"></sequenceFlow>
</subProcess>
<endEvent id="sid-663B115F-4E77-4840-AF6D-4DC395346A3B" name="error1">
<extensionElements>
<activiti:executionListener event="start" expression="${execution.setVariable('errorCode', 'test1')}"></activiti:executionListener>
</extensionElements>
<errorEventDefinition errorRef="test1"></errorEventDefinition>
</endEvent>
<endEvent id="sid-0DFFA7C5-7285-4821-965D-62E07109A814" name="error2">
<extensionElements>
<activiti:executionListener event="start" expression="${execution.setVariable('errorCode', 'test2')}"></activiti:executionListener>
</extensionElements>
<errorEventDefinition errorRef="test2"></errorEventDefinition>
</endEvent>
<exclusiveGateway id="sid-097255AB-DE5F-41C7-9B1F-36A38DCCE070"></exclusiveGateway>
<userTask id="sid-7CB08206-23FF-428B-BEDA-E054A6956675" activiti:assignee="kermit">
<extensionElements>
<activiti:formProperty id="test" name="test" type="long" variable="test"></activiti:formProperty>
</extensionElements>
</userTask>
<sequenceFlow id="sid-748596F0-9AF1-48C6-B30B-AC339FE60CB9" sourceRef="sid-D22C5BB2-35E5-4703-8E85-AB30A3C3B229" targetRef="sid-7CB08206-23FF-428B-BEDA-E054A6956675"></sequenceFlow>
<sequenceFlow id="sid-5770D9AF-FC80-4BCE-80BE-3CB794059242" sourceRef="sid-7CB08206-23FF-428B-BEDA-E054A6956675" targetRef="sid-097255AB-DE5F-41C7-9B1F-36A38DCCE070"></sequenceFlow>
<sequenceFlow id="sid-ACDE23D9-50BC-4338-95BE-5BD12A3EAFA4" sourceRef="sid-097255AB-DE5F-41C7-9B1F-36A38DCCE070" targetRef="sid-663B115F-4E77-4840-AF6D-4DC395346A3B">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${test > 10}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="sid-1D4545A6-B0DD-416E-B4D7-7B4D584B3E22" sourceRef="sid-097255AB-DE5F-41C7-9B1F-36A38DCCE070" targetRef="sid-0DFFA7C5-7285-4821-965D-62E07109A814">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${test <= 10 and test > 5}]]></conditionExpression>
</sequenceFlow>
<scriptTask id="sid-5B0D42C0-980D-435E-A316-BAEDBED63D91" name="error3" scriptFormat="JavaScript" activiti:autoStoreVariables="false">
<script><![CDATA[execution.setVariable('errorCode', 'test3');
throw new org.activiti.engine.delegate.BpmnError("test3");]]></script>
</scriptTask>
<endEvent id="sid-B50E5873-8E4A-4715-BE02-CFC713423378"></endEvent>
<sequenceFlow id="sid-DE54EB4D-C610-4A3C-A59A-CE39873C30EB" sourceRef="sid-5B0D42C0-980D-435E-A316-BAEDBED63D91" targetRef="sid-B50E5873-8E4A-4715-BE02-CFC713423378"></sequenceFlow>
<sequenceFlow id="sid-070E5BCC-3A36-428D-A91C-4DCC52A565C6" sourceRef="sid-097255AB-DE5F-41C7-9B1F-36A38DCCE070" targetRef="sid-5B0D42C0-980D-435E-A316-BAEDBED63D91">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${test <= 5}]]></conditionExpression>
</sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_process">
<bpmndi:BPMNPlane bpmnElement="process" id="BPMNPlane_process">
<bpmndi:BPMNShape bpmnElement="sid-D22C5BB2-35E5-4703-8E85-AB30A3C3B229" id="BPMNShape_sid-D22C5BB2-35E5-4703-8E85-AB30A3C3B229">
<omgdc:Bounds height="30.0" width="30.0" x="45.000000000000014" y="65.00000000000001"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-F0F655FC-61D4-46BA-8251-6BF554FF53F2" id="BPMNShape_sid-F0F655FC-61D4-46BA-8251-6BF554FF53F2">
<omgdc:Bounds height="127.99999999999997" width="482.0" x="45.00000000000001" y="180.00000000000003"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-1696D132-04C3-4AF3-A94C-EC986972FF63" id="BPMNShape_sid-1696D132-04C3-4AF3-A94C-EC986972FF63">
<omgdc:Bounds height="30.0" width="30.000000000000007" x="105.00000000000006" y="220.00000000000006"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="test1" id="BPMNShape_test1">
<omgdc:Bounds height="80.0" width="99.99999999999997" x="230.50000000000003" y="195.00000000000003"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-9113B09B-C3BF-4192-8DED-8CF5A5E8E132" id="BPMNShape_sid-9113B09B-C3BF-4192-8DED-8CF5A5E8E132">
<omgdc:Bounds height="28.0" width="28.000000000000007" x="415.55554563616516" y="221.0000000000001"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-663B115F-4E77-4840-AF6D-4DC395346A3B" id="BPMNShape_sid-663B115F-4E77-4840-AF6D-4DC395346A3B">
<omgdc:Bounds height="28.0" width="28.0" x="585.0000000000002" y="15.000000000000002"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-0DFFA7C5-7285-4821-965D-62E07109A814" id="BPMNShape_sid-0DFFA7C5-7285-4821-965D-62E07109A814">
<omgdc:Bounds height="28.0" width="28.0" x="600.0000000000002" y="90.00000000000001"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-097255AB-DE5F-41C7-9B1F-36A38DCCE070" id="BPMNShape_sid-097255AB-DE5F-41C7-9B1F-36A38DCCE070">
<omgdc:Bounds height="39.99999999999999" width="40.0" x="300.00000000000006" y="60.00000000000001"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-7CB08206-23FF-428B-BEDA-E054A6956675" id="BPMNShape_sid-7CB08206-23FF-428B-BEDA-E054A6956675">
<omgdc:Bounds height="80.0" width="100.0" x="135.00000000000003" y="40.00000000000001"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-5B0D42C0-980D-435E-A316-BAEDBED63D91" id="BPMNShape_sid-5B0D42C0-980D-435E-A316-BAEDBED63D91">
<omgdc:Bounds height="80.0" width="100.0" x="585.0000000000001" y="153.99999735090466"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="sid-B50E5873-8E4A-4715-BE02-CFC713423378" id="BPMNShape_sid-B50E5873-8E4A-4715-BE02-CFC713423378">
<omgdc:Bounds height="28.0" width="28.0" x="750.0000000000001" y="179.9999973509047"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="sid-A476028E-9173-4989-8061-1D334A745B9E" id="BPMNEdge_sid-A476028E-9173-4989-8061-1D334A745B9E">
<omgdi:waypoint x="135.00000000000006" y="235.00000000000006"></omgdi:waypoint>
<omgdi:waypoint x="230.50000000000003" y="235.00000000000006"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sid-ACDE23D9-50BC-4338-95BE-5BD12A3EAFA4" id="BPMNEdge_sid-ACDE23D9-50BC-4338-95BE-5BD12A3EAFA4">
<omgdi:waypoint x="336.909090909091" y="76.9090909090909"></omgdi:waypoint>
<omgdi:waypoint x="585.2281967654175" y="31.517426397719447"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sid-070E5BCC-3A36-428D-A91C-4DCC52A565C6" id="BPMNEdge_sid-070E5BCC-3A36-428D-A91C-4DCC52A565C6">
<omgdi:waypoint x="334.46144868454496" y="85.53855131545512"></omgdi:waypoint>
<omgdi:waypoint x="585.0000000000001" y="175.95548266872586"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sid-1D4545A6-B0DD-416E-B4D7-7B4D584B3E22" id="BPMNEdge_sid-1D4545A6-B0DD-416E-B4D7-7B4D584B3E22">
<omgdi:waypoint x="338.4905660377359" y="81.50943396226415"></omgdi:waypoint>
<omgdi:waypoint x="600.0464153784837" y="102.86093186763132"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sid-748596F0-9AF1-48C6-B30B-AC339FE60CB9" id="BPMNEdge_sid-748596F0-9AF1-48C6-B30B-AC339FE60CB9">
<omgdi:waypoint x="75.00000000000001" y="80.00000000000001"></omgdi:waypoint>
<omgdi:waypoint x="135.00000000000003" y="80.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sid-126CBABD-B23C-4CA2-93D4-44B099929760" id="BPMNEdge_sid-126CBABD-B23C-4CA2-93D4-44B099929760">
<omgdi:waypoint x="330.5" y="235.00000000000006"></omgdi:waypoint>
<omgdi:waypoint x="415.55554563616516" y="235.0000000000001"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sid-5770D9AF-FC80-4BCE-80BE-3CB794059242" id="BPMNEdge_sid-5770D9AF-FC80-4BCE-80BE-3CB794059242">
<omgdi:waypoint x="235.00000000000003" y="80.0"></omgdi:waypoint>
<omgdi:waypoint x="300.00000000000006" y="80.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="sid-DE54EB4D-C610-4A3C-A59A-CE39873C30EB" id="BPMNEdge_sid-DE54EB4D-C610-4A3C-A59A-CE39873C30EB">
<omgdi:waypoint x="685.0000000000001" y="193.99999735090466"></omgdi:waypoint>
<omgdi:waypoint x="750.0000000000001" y="193.9999973509047"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>

stanlyhamburg
Active Member

Re: Activiti 5.22: Multiple (throw) end error event, one/ multiple (catch) start error events in Event-Subprocess

Thank you, Daisuke:

Our design (at the moment):

1. Catch in ScriptTask any Exceptions and set information about in special "Error pr.inst. variables"

2. Go to Fail path (transition, sequence) and throw by Throw End Event

3. Catch in Event Subprocess by one Start Error Event

4a. Classificate Exceptions by special "Error pr.inst. variables"

4b. We check, if you suggestion can be an alternative

(HistoricActivityInstanceQuery     executionId(String executionId))

Are you sure with fetching of historic var ? (That are normal process variables)

daisuke-yoshimo
Senior Member

Re: Activiti 5.22: Multiple (throw) end error event, one/ multiple (catch) start error events in Event-Subprocess

> 1. Catch in ScriptTask any Exceptions and set information about in special "Error pr.inst. variables"

This means that the processing details up to the place where the exception occurred is committed, but is it okay?

Also, there is no point in catching java.lang.Error.

> 4a. Classificate Exceptions by special "Error pr.inst. variables"
> (HistoricActivityInstanceQuery executionId(String executionId))
> Are you sure with fetching of historic var ? (That are normal process variables)

Yeah. My suggestion is to classificate exceptions by normal process variable.
Since history table size is large, you should get variable from RuntimeService not HistoryService.