Skip to content

Commit

Permalink
[JBPM-9961] Process with multiple timer startNodes only triggers one
Browse files Browse the repository at this point in the history
  • Loading branch information
elguardian committed Dec 16, 2021
1 parent 8dc5c79 commit 5e8f998
Show file tree
Hide file tree
Showing 4 changed files with 229 additions and 3 deletions.
Expand Up @@ -350,7 +350,7 @@ public void execute(JobContext c) {
if (ctx.getTrigger().hasNextFireTime() == null) {
ctx.getTimer().setPeriod(0);
}
((ProcessRuntimeImpl)kruntime.getProcessRuntime()).startProcess(ctx.getProcessId(), ctx.getParamaeters(), "timer");
((ProcessRuntimeImpl)kruntime.getProcessRuntime()).startProcess(ctx.getProcessId(), ctx.getParamaeters(), "timer-" + ctx.getTimer().getName());

if (ctx.getTimer().getPeriod() == 0) {
tm.getTimerMap().remove(ctx.getTimer().getId());
Expand Down
Expand Up @@ -134,8 +134,8 @@ public StartNode getStart(String trigger) {
}
}
} else if (start.getTimer() != null) {

if ("timer".equals(trigger)) {
String name = "timer-"+ start.getName();
if (name.equals(trigger)) {
return start;
}
}
Expand Down
Expand Up @@ -51,6 +51,9 @@ public class StartEventTest extends JbpmTestCase {
private static final String TIMER_DURATION = "org/jbpm/test/functional/event/StartEvent-timer-duration.bpmn2";
private static final String TIMER_DURATION_ID = "org.jbpm.test.functional.event.StartEvent-timer-duration";

private static final String MULTIPLE_START_TIMER = "org/jbpm/test/functional/event/StartEvent-MultipleTimers.bpmn2";
private static final String MULTIPLE_START_TIMER_ID = "org.jbpm.test.functional.event.StartEvent-MultipleTimers";

public StartEventTest() {
super(false);
}
Expand Down Expand Up @@ -192,4 +195,31 @@ public void testDelayingTimerStartEvent() throws Exception {
process.clear();
}

@Test
public void testStartMultipleTimer() throws Exception {
KieSession ksession = createKSession(MULTIPLE_START_TIMER);

IterableProcessEventListener events = new IterableProcessEventListener();
TrackingProcessEventListener process = new TrackingProcessEventListener(2);
ksession.addEventListener(events);
ksession.addEventListener(process);

process.waitForProcessToComplete(4000L);

Assertions.assertThat(process.wasProcessStarted(MULTIPLE_START_TIMER_ID)).isTrue();
Assertions.assertThat(process.wasProcessCompleted(MULTIPLE_START_TIMER_ID)).isTrue();
assertProcessStarted(events, MULTIPLE_START_TIMER_ID);
assertNextNode(events, "2s");
assertNextNode(events, "Task2");
assertNextNode(events, "end1");
assertProcessCompleted(events, MULTIPLE_START_TIMER_ID);

assertProcessStarted(events, MULTIPLE_START_TIMER_ID);
assertNextNode(events, "3s");
assertNextNode(events, "Task1");
assertNextNode(events, "end2");
assertProcessCompleted(events, MULTIPLE_START_TIMER_ID);

}

}
@@ -0,0 +1,196 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.omg.org/bpmn20" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:bpsim="http://www.bpsim.org/schemas/1.0" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:drools="http://www.jboss.org/drools" id="_QLqhUE3NEey5lbzIH7CA8w" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd http://www.jboss.org/drools drools.xsd http://www.bpsim.org/schemas/1.0 bpsim.xsd http://www.omg.org/spec/DD/20100524/DC DC.xsd http://www.omg.org/spec/DD/20100524/DI DI.xsd " exporter="jBPM Process Modeler" exporterVersion="2.0" targetNamespace="http://www.omg.org/bpmn20">
<bpmn2:process id="org.jbpm.test.functional.event.StartEvent-MultipleTimers" drools:packageName="org.jbpm" drools:version="1.0" drools:adHoc="false" name="timers" isExecutable="true" processType="Public">
<bpmn2:sequenceFlow id="_CB900599-9A89-4723-B1EE-60F0DC4894CD" sourceRef="_594DAD1E-1245-49A4-AEB3-42FC280B2CB7" targetRef="_FCAB1610-3E8C-4EB4-9223-FA7989A06313">
<bpmn2:extensionElements>
<drools:metaData name="isAutoConnection.source">
<drools:metaValue><![CDATA[true]]></drools:metaValue>
</drools:metaData>
<drools:metaData name="isAutoConnection.target">
<drools:metaValue><![CDATA[true]]></drools:metaValue>
</drools:metaData>
</bpmn2:extensionElements>
</bpmn2:sequenceFlow>
<bpmn2:sequenceFlow id="_9610EE8F-180F-48A2-966A-982F476CEB52" sourceRef="_B362EEDD-827B-4CA6-93C0-CE51014EC177" targetRef="_B771E0CF-BCF7-4BF6-9F82-F7695A79FC57">
<bpmn2:extensionElements>
<drools:metaData name="isAutoConnection.source">
<drools:metaValue><![CDATA[true]]></drools:metaValue>
</drools:metaData>
<drools:metaData name="isAutoConnection.target">
<drools:metaValue><![CDATA[true]]></drools:metaValue>
</drools:metaData>
</bpmn2:extensionElements>
</bpmn2:sequenceFlow>
<bpmn2:sequenceFlow id="_FCBB303D-5573-45D9-ABA4-CB28E82F19D4" sourceRef="_570D2C24-5474-4436-8D80-DE29BE4AF824" targetRef="_B362EEDD-827B-4CA6-93C0-CE51014EC177">
<bpmn2:extensionElements>
<drools:metaData name="isAutoConnection.source">
<drools:metaValue><![CDATA[true]]></drools:metaValue>
</drools:metaData>
<drools:metaData name="isAutoConnection.target">
<drools:metaValue><![CDATA[true]]></drools:metaValue>
</drools:metaData>
</bpmn2:extensionElements>
</bpmn2:sequenceFlow>
<bpmn2:sequenceFlow id="_C2F596F3-671A-4A5C-AA91-3A513126C83C" sourceRef="_FCAB1610-3E8C-4EB4-9223-FA7989A06313" targetRef="_E000FE5E-ECED-4DDB-B42D-4C9E40A54618">
<bpmn2:extensionElements>
<drools:metaData name="isAutoConnection.source">
<drools:metaValue><![CDATA[true]]></drools:metaValue>
</drools:metaData>
<drools:metaData name="isAutoConnection.target">
<drools:metaValue><![CDATA[true]]></drools:metaValue>
</drools:metaData>
</bpmn2:extensionElements>
</bpmn2:sequenceFlow>
<bpmn2:scriptTask id="_FCAB1610-3E8C-4EB4-9223-FA7989A06313" name="Task1" scriptFormat="http://www.java.com/java">
<bpmn2:extensionElements>
<drools:metaData name="elementname">
<drools:metaValue><![CDATA[Task]]></drools:metaValue>
</drools:metaData>
</bpmn2:extensionElements>
<bpmn2:incoming>_CB900599-9A89-4723-B1EE-60F0DC4894CD</bpmn2:incoming>
<bpmn2:outgoing>_C2F596F3-671A-4A5C-AA91-3A513126C83C</bpmn2:outgoing>
<bpmn2:script><![CDATA[System.out.println("timer 3s");]]></bpmn2:script>
</bpmn2:scriptTask>
<bpmn2:startEvent id="_570D2C24-5474-4436-8D80-DE29BE4AF824" name="2s">
<bpmn2:extensionElements>
<drools:metaData name="elementname">
<drools:metaValue><![CDATA[2s]]></drools:metaValue>
</drools:metaData>
</bpmn2:extensionElements>
<bpmn2:outgoing>_FCBB303D-5573-45D9-ABA4-CB28E82F19D4</bpmn2:outgoing>
<bpmn2:timerEventDefinition id="_QLsWgE3NEey5lbzIH7CA8w">
<bpmn2:timeCycle xsi:type="bpmn2:tFormalExpression" id="_QLsWgU3NEey5lbzIH7CA8w" language="none">R1/PT2S</bpmn2:timeCycle>
</bpmn2:timerEventDefinition>
</bpmn2:startEvent>
<bpmn2:endEvent id="_B771E0CF-BCF7-4BF6-9F82-F7695A79FC57" name="end1">
<bpmn2:incoming>_9610EE8F-180F-48A2-966A-982F476CEB52</bpmn2:incoming>
</bpmn2:endEvent>
<bpmn2:startEvent id="_594DAD1E-1245-49A4-AEB3-42FC280B2CB7" name="3s">
<bpmn2:extensionElements>
<drools:metaData name="elementname">
<drools:metaValue><![CDATA[3s]]></drools:metaValue>
</drools:metaData>
</bpmn2:extensionElements>
<bpmn2:outgoing>_CB900599-9A89-4723-B1EE-60F0DC4894CD</bpmn2:outgoing>
<bpmn2:timerEventDefinition id="_QLsWgk3NEey5lbzIH7CA8w">
<bpmn2:timeCycle xsi:type="bpmn2:tFormalExpression" id="_QLsWg03NEey5lbzIH7CA8w" language="none">R1/PT3S</bpmn2:timeCycle>
</bpmn2:timerEventDefinition>
</bpmn2:startEvent>
<bpmn2:scriptTask id="_B362EEDD-827B-4CA6-93C0-CE51014EC177" name="Task2" scriptFormat="http://www.java.com/java">
<bpmn2:extensionElements>
<drools:metaData name="elementname">
<drools:metaValue><![CDATA[Task]]></drools:metaValue>
</drools:metaData>
</bpmn2:extensionElements>
<bpmn2:incoming>_FCBB303D-5573-45D9-ABA4-CB28E82F19D4</bpmn2:incoming>
<bpmn2:outgoing>_9610EE8F-180F-48A2-966A-982F476CEB52</bpmn2:outgoing>
<bpmn2:script><![CDATA[System.out.println("timer 2s");]]></bpmn2:script>
</bpmn2:scriptTask>
<bpmn2:endEvent id="_E000FE5E-ECED-4DDB-B42D-4C9E40A54618" name="end2">
<bpmn2:incoming>_C2F596F3-671A-4A5C-AA91-3A513126C83C</bpmn2:incoming>
</bpmn2:endEvent>
</bpmn2:process>
<bpmndi:BPMNDiagram id="_QLsWhE3NEey5lbzIH7CA8w">
<bpmndi:BPMNPlane id="_QLsWhU3NEey5lbzIH7CA8w" bpmnElement="startNodes.timers">
<bpmndi:BPMNShape id="shape__E000FE5E-ECED-4DDB-B42D-4C9E40A54618" bpmnElement="_E000FE5E-ECED-4DDB-B42D-4C9E40A54618">
<dc:Bounds height="56.0" width="56.0" x="714.0" y="283.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="shape__B362EEDD-827B-4CA6-93C0-CE51014EC177" bpmnElement="_B362EEDD-827B-4CA6-93C0-CE51014EC177">
<dc:Bounds height="102.0" width="154.0" x="480.0" y="63.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="shape__594DAD1E-1245-49A4-AEB3-42FC280B2CB7" bpmnElement="_594DAD1E-1245-49A4-AEB3-42FC280B2CB7">
<dc:Bounds height="56.0" width="56.0" x="331.0" y="283.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="shape__B771E0CF-BCF7-4BF6-9F82-F7695A79FC57" bpmnElement="_B771E0CF-BCF7-4BF6-9F82-F7695A79FC57">
<dc:Bounds height="56.0" width="56.0" x="714.0" y="86.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="shape__570D2C24-5474-4436-8D80-DE29BE4AF824" bpmnElement="_570D2C24-5474-4436-8D80-DE29BE4AF824">
<dc:Bounds height="56.0" width="56.0" x="331.0" y="86.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="shape__FCAB1610-3E8C-4EB4-9223-FA7989A06313" bpmnElement="_FCAB1610-3E8C-4EB4-9223-FA7989A06313">
<dc:Bounds height="102.0" width="154.0" x="480.0" y="260.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="edge_shape__FCAB1610-3E8C-4EB4-9223-FA7989A06313_to_shape__E000FE5E-ECED-4DDB-B42D-4C9E40A54618" bpmnElement="_C2F596F3-671A-4A5C-AA91-3A513126C83C">
<di:waypoint xsi:type="dc:Point" x="634.0" y="311.0"/>
<di:waypoint xsi:type="dc:Point" x="714.0" y="311.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="edge_shape__570D2C24-5474-4436-8D80-DE29BE4AF824_to_shape__B362EEDD-827B-4CA6-93C0-CE51014EC177" bpmnElement="_FCBB303D-5573-45D9-ABA4-CB28E82F19D4">
<di:waypoint xsi:type="dc:Point" x="387.0" y="114.0"/>
<di:waypoint xsi:type="dc:Point" x="480.0" y="114.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="edge_shape__B362EEDD-827B-4CA6-93C0-CE51014EC177_to_shape__B771E0CF-BCF7-4BF6-9F82-F7695A79FC57" bpmnElement="_9610EE8F-180F-48A2-966A-982F476CEB52">
<di:waypoint xsi:type="dc:Point" x="634.0" y="114.0"/>
<di:waypoint xsi:type="dc:Point" x="714.0" y="114.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="edge_shape__594DAD1E-1245-49A4-AEB3-42FC280B2CB7_to_shape__FCAB1610-3E8C-4EB4-9223-FA7989A06313" bpmnElement="_CB900599-9A89-4723-B1EE-60F0DC4894CD">
<di:waypoint xsi:type="dc:Point" x="387.0" y="311.0"/>
<di:waypoint xsi:type="dc:Point" x="480.0" y="311.0"/>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
<bpmn2:relationship id="_QLs9kE3NEey5lbzIH7CA8w" type="BPSimData">
<bpmn2:extensionElements>
<bpsim:BPSimData>
<bpsim:Scenario xsi:type="bpsim:Scenario" id="default" name="Simulationscenario">
<bpsim:ScenarioParameters xsi:type="bpsim:ScenarioParameters"/>
<bpsim:ElementParameters xsi:type="bpsim:ElementParameters" elementRef="_B362EEDD-827B-4CA6-93C0-CE51014EC177" id="_QLs9kU3NEey5lbzIH7CA8w">
<bpsim:TimeParameters xsi:type="bpsim:TimeParameters">
<bpsim:ProcessingTime xsi:type="bpsim:Parameter">
<bpsim:NormalDistribution mean="0.0" standardDeviation="0.0"/>
</bpsim:ProcessingTime>
</bpsim:TimeParameters>
<bpsim:ResourceParameters xsi:type="bpsim:ResourceParameters">
<bpsim:Availability xsi:type="bpsim:Parameter">
<bpsim:FloatingParameter value="0.0"/>
</bpsim:Availability>
<bpsim:Quantity xsi:type="bpsim:Parameter">
<bpsim:FloatingParameter value="0.0"/>
</bpsim:Quantity>
</bpsim:ResourceParameters>
<bpsim:CostParameters xsi:type="bpsim:CostParameters">
<bpsim:UnitCost xsi:type="bpsim:Parameter">
<bpsim:FloatingParameter value="0.0"/>
</bpsim:UnitCost>
</bpsim:CostParameters>
</bpsim:ElementParameters>
<bpsim:ElementParameters xsi:type="bpsim:ElementParameters" elementRef="_594DAD1E-1245-49A4-AEB3-42FC280B2CB7" id="_QLs9kk3NEey5lbzIH7CA8w">
<bpsim:TimeParameters xsi:type="bpsim:TimeParameters">
<bpsim:ProcessingTime xsi:type="bpsim:Parameter">
<bpsim:NormalDistribution mean="0.0" standardDeviation="0.0"/>
</bpsim:ProcessingTime>
</bpsim:TimeParameters>
</bpsim:ElementParameters>
<bpsim:ElementParameters xsi:type="bpsim:ElementParameters" elementRef="_570D2C24-5474-4436-8D80-DE29BE4AF824" id="_QLs9k03NEey5lbzIH7CA8w">
<bpsim:TimeParameters xsi:type="bpsim:TimeParameters">
<bpsim:ProcessingTime xsi:type="bpsim:Parameter">
<bpsim:NormalDistribution mean="0.0" standardDeviation="0.0"/>
</bpsim:ProcessingTime>
</bpsim:TimeParameters>
</bpsim:ElementParameters>
<bpsim:ElementParameters xsi:type="bpsim:ElementParameters" elementRef="_FCAB1610-3E8C-4EB4-9223-FA7989A06313" id="_QLs9lE3NEey5lbzIH7CA8w">
<bpsim:TimeParameters xsi:type="bpsim:TimeParameters">
<bpsim:ProcessingTime xsi:type="bpsim:Parameter">
<bpsim:NormalDistribution mean="0.0" standardDeviation="0.0"/>
</bpsim:ProcessingTime>
</bpsim:TimeParameters>
<bpsim:ResourceParameters xsi:type="bpsim:ResourceParameters">
<bpsim:Availability xsi:type="bpsim:Parameter">
<bpsim:FloatingParameter value="0.0"/>
</bpsim:Availability>
<bpsim:Quantity xsi:type="bpsim:Parameter">
<bpsim:FloatingParameter value="0.0"/>
</bpsim:Quantity>
</bpsim:ResourceParameters>
<bpsim:CostParameters xsi:type="bpsim:CostParameters">
<bpsim:UnitCost xsi:type="bpsim:Parameter">
<bpsim:FloatingParameter value="0.0"/>
</bpsim:UnitCost>
</bpsim:CostParameters>
</bpsim:ElementParameters>
</bpsim:Scenario>
</bpsim:BPSimData>
</bpmn2:extensionElements>
<bpmn2:source>_QLqhUE3NEey5lbzIH7CA8w</bpmn2:source>
<bpmn2:target>_QLqhUE3NEey5lbzIH7CA8w</bpmn2:target>
</bpmn2:relationship>
</bpmn2:definitions>

0 comments on commit 5e8f998

Please sign in to comment.