Skip to content

Commit b062c7b

Browse files
committed
Merge remote-tracking branch
'origin/issue/509_BpmnError-for-MessageSendTaskDelegate' into develop
2 parents 5c6c95f + 6eef8fc commit b062c7b

7 files changed

Lines changed: 594 additions & 446 deletions

File tree

dsf-bpe/dsf-bpe-process-api-v2-impl/src/main/java/dev/dsf/bpe/v2/activity/MessageSendTaskDelegate.java

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,7 @@ public void execute(DelegateExecution execution) throws Exception
4747
// do not stop process execution
4848
catch (ErrorBoundaryEvent event)
4949
{
50-
MessageSendTaskErrorHandler handler = delegate.getErrorHandler();
51-
if (handler != null)
52-
event = handler.handleErrorBoundaryEvent(api, variables, event);
53-
54-
if (event != null)
55-
throw new BpmnError(event.getErrorCode(), event.getErrorMessage(), event);
56-
// else, do nothing if event was absorbed by error handler
50+
handleErrorBoundaryEvent(variables, event);
5751
}
5852
// stop process execution if exception not absorbed by error handler
5953
catch (Exception exception)
@@ -62,10 +56,25 @@ public void execute(DelegateExecution execution) throws Exception
6256
if (handler != null)
6357
exception = handler.handleException(api, variables, sendTaskValues, exception);
6458

65-
if (exception != null)
59+
// do not stop process execution if exception translated to error boundary event
60+
if (exception instanceof ErrorBoundaryEvent event)
61+
handleErrorBoundaryEvent(variables, event);
62+
63+
else if (exception != null)
6664
execution.getProcessEngine().getRuntimeService().deleteProcessInstance(execution.getProcessInstanceId(),
6765
exception.getMessage());
6866
// else, do nothing if exception was absorbed by error handler
6967
}
7068
}
69+
70+
private void handleErrorBoundaryEvent(Variables variables, ErrorBoundaryEvent event)
71+
{
72+
MessageSendTaskErrorHandler handler = delegate.getErrorHandler();
73+
if (handler != null)
74+
event = handler.handleErrorBoundaryEvent(api, variables, event);
75+
76+
// do nothing if event was absorbed by error handler
77+
if (event != null)
78+
throw new BpmnError(event.getErrorCode(), event.getErrorMessage(), event);
79+
}
7180
}

dsf-bpe/dsf-bpe-server/src/test/java/dev/dsf/bpe/integration/PluginV2IntegrationTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ public void startSendTaskTest() throws Exception
111111
executePluginTest(createTestTask("SendTaskTest"));
112112
}
113113

114+
@Test
115+
public void startSendTaskErrorBoundaryEventTestThrow() throws Exception
116+
{
117+
executePluginTest(createTestTask("SendTaskErrorBoundaryEventTestThrow"));
118+
}
119+
114120
@Test
115121
public void startFieldInjectionTest() throws Exception
116122
{

dsf-bpe/dsf-bpe-test-plugin-v1/src/main/resources/bpe/test.bpmn

Lines changed: 59 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
limitations under the License.
1717
1818
-->
19-
<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" id="Definitions_1yb5vw3" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.31.0">
19+
<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" id="Definitions_1yb5vw3" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.46.1">
2020
<bpmn:process id="dsfdev_test" isExecutable="true" camunda:versionTag="#{version}">
2121
<bpmn:startEvent id="StartEvent">
2222
<bpmn:outgoing>Flow_112zq99</bpmn:outgoing>
@@ -37,13 +37,14 @@
3737
<bpmn:incoming>Flow_112zq99</bpmn:incoming>
3838
<bpmn:outgoing>Flow_1bqddk1</bpmn:outgoing>
3939
</bpmn:serviceTask>
40-
<bpmn:exclusiveGateway id="Gateway_0eszi2t">
40+
<bpmn:exclusiveGateway id="Gateway_0eszi2t" default="Flow_04yuv8k">
4141
<bpmn:incoming>Flow_1bqddk1</bpmn:incoming>
4242
<bpmn:outgoing>Flow_14rzc0j</bpmn:outgoing>
4343
<bpmn:outgoing>Flow_0iy74da</bpmn:outgoing>
4444
<bpmn:outgoing>Flow_1h0pa8u</bpmn:outgoing>
4545
<bpmn:outgoing>Flow_1hhwby8</bpmn:outgoing>
4646
<bpmn:outgoing>Flow_0u49lp5</bpmn:outgoing>
47+
<bpmn:outgoing>Flow_04yuv8k</bpmn:outgoing>
4748
</bpmn:exclusiveGateway>
4849
<bpmn:sequenceFlow id="Flow_1bqddk1" sourceRef="TestActivitySelector" targetRef="Gateway_0eszi2t" />
4950
<bpmn:sequenceFlow id="Flow_14rzc0j" sourceRef="Gateway_0eszi2t" targetRef="ProxyTest">
@@ -88,106 +89,118 @@
8889
<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${testActivity == 'EnvironmentVariableTest'}</bpmn:conditionExpression>
8990
</bpmn:sequenceFlow>
9091
<bpmn:sequenceFlow id="Flow_1xze9pm" sourceRef="EnvironmentVariableTest" targetRef="Gateway_056f6tw" />
92+
<bpmn:endEvent id="Event_0sddf5q">
93+
<bpmn:incoming>Flow_04yuv8k</bpmn:incoming>
94+
</bpmn:endEvent>
95+
<bpmn:sequenceFlow id="Flow_04yuv8k" sourceRef="Gateway_0eszi2t" targetRef="Event_0sddf5q" />
9196
</bpmn:process>
9297
<bpmn:message id="Message_1nn2wdw" name="start" />
9398
<bpmn:message id="Message_2iq6v5e" name="proxyTest" />
9499
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
95100
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="dsfdev_test">
96101
<bpmndi:BPMNShape id="StartEvent_0x5gijn_di" bpmnElement="StartEvent">
97-
<dc:Bounds x="152" y="102" width="36" height="36" />
102+
<dc:Bounds x="152" y="172" width="36" height="36" />
98103
</bpmndi:BPMNShape>
99104
<bpmndi:BPMNShape id="ServiceTask_0um3ad2_di" bpmnElement="ApiTest">
100-
<dc:Bounds x="480" y="80" width="100" height="80" />
105+
<dc:Bounds x="480" y="150" width="100" height="80" />
101106
<bpmndi:BPMNLabel />
102107
</bpmndi:BPMNShape>
103108
<bpmndi:BPMNShape id="BPMNShape_161ssjb" bpmnElement="ProxyTest">
104-
<dc:Bounds x="480" y="190" width="100" height="80" />
109+
<dc:Bounds x="480" y="260" width="100" height="80" />
105110
<bpmndi:BPMNLabel />
106111
</bpmndi:BPMNShape>
107112
<bpmndi:BPMNShape id="EndEvent_0xd0x8k_di" bpmnElement="EndEvent">
108-
<dc:Bounds x="712" y="102" width="36" height="36" />
113+
<dc:Bounds x="712" y="172" width="36" height="36" />
109114
</bpmndi:BPMNShape>
110115
<bpmndi:BPMNShape id="Activity_1x0k0hn_di" bpmnElement="TestActivitySelector">
111-
<dc:Bounds x="230" y="80" width="100" height="80" />
116+
<dc:Bounds x="230" y="150" width="100" height="80" />
112117
<bpmndi:BPMNLabel />
113118
</bpmndi:BPMNShape>
114119
<bpmndi:BPMNShape id="Gateway_0eszi2t_di" bpmnElement="Gateway_0eszi2t" isMarkerVisible="true">
115-
<dc:Bounds x="385" y="95" width="50" height="50" />
120+
<dc:Bounds x="385" y="165" width="50" height="50" />
116121
</bpmndi:BPMNShape>
117122
<bpmndi:BPMNShape id="Gateway_056f6tw_di" bpmnElement="Gateway_056f6tw" isMarkerVisible="true">
118-
<dc:Bounds x="625" y="95" width="50" height="50" />
123+
<dc:Bounds x="625" y="165" width="50" height="50" />
119124
</bpmndi:BPMNShape>
120125
<bpmndi:BPMNShape id="BPMNShape_1n4vu6v" bpmnElement="OrganizationProviderTest">
121-
<dc:Bounds x="480" y="300" width="100" height="80" />
126+
<dc:Bounds x="480" y="370" width="100" height="80" />
122127
<bpmndi:BPMNLabel />
123128
</bpmndi:BPMNShape>
124129
<bpmndi:BPMNShape id="BPMNShape_1xcwytq" bpmnElement="EndpointProviderTest">
125-
<dc:Bounds x="480" y="410" width="100" height="80" />
130+
<dc:Bounds x="480" y="480" width="100" height="80" />
126131
<bpmndi:BPMNLabel />
127132
</bpmndi:BPMNShape>
128133
<bpmndi:BPMNShape id="Activity_14a3a5f_di" bpmnElement="EnvironmentVariableTest">
129-
<dc:Bounds x="480" y="520" width="100" height="80" />
134+
<dc:Bounds x="480" y="590" width="100" height="80" />
130135
<bpmndi:BPMNLabel />
131136
</bpmndi:BPMNShape>
137+
<bpmndi:BPMNShape id="Event_0sddf5q_di" bpmnElement="Event_0sddf5q">
138+
<dc:Bounds x="512" y="82" width="36" height="36" />
139+
</bpmndi:BPMNShape>
132140
<bpmndi:BPMNEdge id="Flow_1bqddk1_di" bpmnElement="Flow_1bqddk1">
133-
<di:waypoint x="330" y="120" />
134-
<di:waypoint x="385" y="120" />
141+
<di:waypoint x="330" y="190" />
142+
<di:waypoint x="385" y="190" />
135143
</bpmndi:BPMNEdge>
136144
<bpmndi:BPMNEdge id="Flow_14rzc0j_di" bpmnElement="Flow_14rzc0j">
137-
<di:waypoint x="410" y="145" />
138-
<di:waypoint x="410" y="230" />
139-
<di:waypoint x="480" y="230" />
145+
<di:waypoint x="410" y="215" />
146+
<di:waypoint x="410" y="300" />
147+
<di:waypoint x="480" y="300" />
140148
</bpmndi:BPMNEdge>
141149
<bpmndi:BPMNEdge id="Flow_112zq99_di" bpmnElement="Flow_112zq99">
142-
<di:waypoint x="188" y="120" />
143-
<di:waypoint x="230" y="120" />
150+
<di:waypoint x="188" y="190" />
151+
<di:waypoint x="230" y="190" />
144152
</bpmndi:BPMNEdge>
145153
<bpmndi:BPMNEdge id="Flow_0iy74da_di" bpmnElement="Flow_0iy74da">
146-
<di:waypoint x="435" y="120" />
147-
<di:waypoint x="480" y="120" />
154+
<di:waypoint x="435" y="190" />
155+
<di:waypoint x="480" y="190" />
148156
</bpmndi:BPMNEdge>
149157
<bpmndi:BPMNEdge id="Flow_08zzudo_di" bpmnElement="Flow_08zzudo">
150-
<di:waypoint x="580" y="230" />
151-
<di:waypoint x="650" y="230" />
152-
<di:waypoint x="650" y="145" />
158+
<di:waypoint x="580" y="300" />
159+
<di:waypoint x="650" y="300" />
160+
<di:waypoint x="650" y="215" />
153161
</bpmndi:BPMNEdge>
154162
<bpmndi:BPMNEdge id="Flow_1mkx5o3_di" bpmnElement="Flow_1mkx5o3">
155-
<di:waypoint x="580" y="120" />
156-
<di:waypoint x="625" y="120" />
163+
<di:waypoint x="580" y="190" />
164+
<di:waypoint x="625" y="190" />
157165
</bpmndi:BPMNEdge>
158166
<bpmndi:BPMNEdge id="Flow_0a1kwg9_di" bpmnElement="Flow_0a1kwg9">
159-
<di:waypoint x="675" y="120" />
160-
<di:waypoint x="712" y="120" />
167+
<di:waypoint x="675" y="190" />
168+
<di:waypoint x="712" y="190" />
161169
</bpmndi:BPMNEdge>
162170
<bpmndi:BPMNEdge id="Flow_1h0pa8u_di" bpmnElement="Flow_1h0pa8u">
163-
<di:waypoint x="410" y="145" />
164-
<di:waypoint x="410" y="340" />
165-
<di:waypoint x="480" y="340" />
171+
<di:waypoint x="410" y="215" />
172+
<di:waypoint x="410" y="410" />
173+
<di:waypoint x="480" y="410" />
166174
</bpmndi:BPMNEdge>
167175
<bpmndi:BPMNEdge id="Flow_0usx9io_di" bpmnElement="Flow_0usx9io">
168-
<di:waypoint x="580" y="340" />
169-
<di:waypoint x="650" y="340" />
170-
<di:waypoint x="650" y="145" />
176+
<di:waypoint x="580" y="410" />
177+
<di:waypoint x="650" y="410" />
178+
<di:waypoint x="650" y="215" />
171179
</bpmndi:BPMNEdge>
172180
<bpmndi:BPMNEdge id="Flow_1hhwby8_di" bpmnElement="Flow_1hhwby8">
173-
<di:waypoint x="410" y="145" />
174-
<di:waypoint x="410" y="450" />
175-
<di:waypoint x="480" y="450" />
181+
<di:waypoint x="410" y="215" />
182+
<di:waypoint x="410" y="520" />
183+
<di:waypoint x="480" y="520" />
176184
</bpmndi:BPMNEdge>
177185
<bpmndi:BPMNEdge id="Flow_1bn9gvv_di" bpmnElement="Flow_1bn9gvv">
178-
<di:waypoint x="580" y="450" />
179-
<di:waypoint x="650" y="450" />
180-
<di:waypoint x="650" y="145" />
186+
<di:waypoint x="580" y="520" />
187+
<di:waypoint x="650" y="520" />
188+
<di:waypoint x="650" y="215" />
181189
</bpmndi:BPMNEdge>
182190
<bpmndi:BPMNEdge id="Flow_0u49lp5_di" bpmnElement="Flow_0u49lp5">
183-
<di:waypoint x="410" y="145" />
184-
<di:waypoint x="410" y="560" />
185-
<di:waypoint x="480" y="560" />
191+
<di:waypoint x="410" y="215" />
192+
<di:waypoint x="410" y="630" />
193+
<di:waypoint x="480" y="630" />
186194
</bpmndi:BPMNEdge>
187195
<bpmndi:BPMNEdge id="Flow_1xze9pm_di" bpmnElement="Flow_1xze9pm">
188-
<di:waypoint x="580" y="560" />
189-
<di:waypoint x="650" y="560" />
190-
<di:waypoint x="650" y="145" />
196+
<di:waypoint x="580" y="630" />
197+
<di:waypoint x="650" y="630" />
198+
<di:waypoint x="650" y="215" />
199+
</bpmndi:BPMNEdge>
200+
<bpmndi:BPMNEdge id="Flow_04yuv8k_di" bpmnElement="Flow_04yuv8k">
201+
<di:waypoint x="410" y="165" />
202+
<di:waypoint x="410" y="100" />
203+
<di:waypoint x="512" y="100" />
191204
</bpmndi:BPMNEdge>
192205
</bpmndi:BPMNPlane>
193206
</bpmndi:BPMNDiagram>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright 2018-2025 Heilbronn University of Applied Sciences
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package dev.dsf.bpe.test.message;
17+
18+
import dev.dsf.bpe.test.AbstractTest;
19+
import dev.dsf.bpe.v2.ProcessPluginApi;
20+
import dev.dsf.bpe.v2.activity.MessageSendTask;
21+
import dev.dsf.bpe.v2.activity.values.SendTaskValues;
22+
import dev.dsf.bpe.v2.error.MessageSendTaskErrorHandler;
23+
import dev.dsf.bpe.v2.error.impl.ExceptionToErrorBoundaryEventTranslationErrorHandler;
24+
import dev.dsf.bpe.v2.variables.Variables;
25+
26+
public class SendTaskErrorBoundaryEventTestThrow extends AbstractTest implements MessageSendTask
27+
{
28+
public static final String TEST_ERROR_CODE = "testErrorCode";
29+
public static final String TEST_ERROR_MESSAGE = "testErrorMessage";
30+
31+
@Override
32+
public void execute(ProcessPluginApi api, Variables variables, SendTaskValues sendTask) throws Exception
33+
{
34+
throw new RuntimeException(TEST_ERROR_MESSAGE);
35+
}
36+
37+
@Override
38+
public MessageSendTaskErrorHandler getErrorHandler()
39+
{
40+
return new ExceptionToErrorBoundaryEventTranslationErrorHandler(_ -> TEST_ERROR_CODE);
41+
}
42+
}

dsf-bpe/dsf-bpe-test-plugin-v2/src/main/java/dev/dsf/bpe/test/spring/config/Config.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import dev.dsf.bpe.test.listener.StartFieldInjectionTestListener;
3131
import dev.dsf.bpe.test.listener.StartSendTaskTestListener;
3232
import dev.dsf.bpe.test.message.ContinueSendTestSend;
33+
import dev.dsf.bpe.test.message.SendTaskErrorBoundaryEventTestThrow;
3334
import dev.dsf.bpe.test.message.SendTaskTest;
3435
import dev.dsf.bpe.test.service.ApiTest;
3536
import dev.dsf.bpe.test.service.AutowireTest;
@@ -90,13 +91,13 @@ public static ActivityPrototypeBeanCreator activityPrototypeBeanCreator()
9091
return new ActivityPrototypeBeanCreator(TestActivitySelector.class, ProxyTest.class, ApiTest.class,
9192
OrganizationProviderTest.class, EndpointProviderTest.class, FhirClientProviderTest.class,
9293
FhirClientConfigProviderTest.class, StartSendTaskTestListener.class, SendTaskTest.class,
93-
StartFieldInjectionTestListener.class, FieldInjectionTest.class, ErrorBoundaryEventTestThrow.class,
94-
ErrorBoundaryEventTestVerify.class, ExceptionTest.class, CompressionServiceTest.class,
95-
ContinueSendTest.class, ContinueSendTestSend.class, ContinueSendTestEvaluate.class,
96-
JsonVariableTestSet.class, JsonVariableTestGet.class, CryptoServiceTest.class,
97-
MimeTypeServiceTest.class, FhirBinaryVariableTestSet.class, FhirBinaryVariableTestGet.class,
98-
DsfClientTest.class, TargetProviderTest.class, DataLoggerTest.class, AutowireTest.class,
99-
QuestionnaireTestAnswer.class, QuestionnaireTestAnswerCheck.class,
94+
SendTaskErrorBoundaryEventTestThrow.class, StartFieldInjectionTestListener.class,
95+
FieldInjectionTest.class, ErrorBoundaryEventTestThrow.class, ErrorBoundaryEventTestVerify.class,
96+
ExceptionTest.class, CompressionServiceTest.class, ContinueSendTest.class, ContinueSendTestSend.class,
97+
ContinueSendTestEvaluate.class, JsonVariableTestSet.class, JsonVariableTestGet.class,
98+
CryptoServiceTest.class, MimeTypeServiceTest.class, FhirBinaryVariableTestSet.class,
99+
FhirBinaryVariableTestGet.class, DsfClientTest.class, TargetProviderTest.class, DataLoggerTest.class,
100+
AutowireTest.class, QuestionnaireTestAnswer.class, QuestionnaireTestAnswerCheck.class,
100101
QuestionnaireTestSetIdentifies.class);
101102
}
102103

0 commit comments

Comments
 (0)