Skip to content

Commit 1e23886

Browse files
committed
reworked autostart process with unique instances based on BPMN signals
The new ping autostart process implementation uses an event based gateway to either wait for a timer to fire after 24 hours or a global signal to abort. The abort signal is send as the first step of the autostart process to stop existing instances and based on a stopPingAutostart Task resource. The new implementation does not require (nor allow) to specify a business-key via Task resource. If a stopPingAutostart Task resource is send while the autostart process is active and not waiting, nothing happens. Stopping the autostart process is only possible while the process is sleeping but then is stopped immediately.
1 parent 81370fb commit 1e23886

File tree

9 files changed

+182
-218
lines changed

9 files changed

+182
-218
lines changed

dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/service/StartTimer.java renamed to dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/service/SetTargetAndConfigureTimer.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package org.highmed.dsf.bpe.service;
22

33
import static org.highmed.dsf.bpe.ConstantsBase.BPMN_EXECUTION_VARIABLE_TARGET;
4-
import static org.highmed.dsf.bpe.ConstantsPing.BPMN_EXECUTION_VARIABLE_STOP_TIMER;
54
import static org.highmed.dsf.bpe.ConstantsPing.BPMN_EXECUTION_VARIABLE_TIMER_INTERVAL;
65
import static org.highmed.dsf.bpe.ConstantsPing.CODESYSTEM_HIGHMED_PING;
76
import static org.highmed.dsf.bpe.ConstantsPing.CODESYSTEM_HIGHMED_PING_VALUE_TIMER_INTERVAL;
87
import static org.highmed.dsf.bpe.ConstantsPing.TIMER_INTERVAL_DEFAULT_VALUE;
98

9+
import java.util.Objects;
10+
11+
import org.camunda.bpm.engine.delegate.BpmnError;
1012
import org.camunda.bpm.engine.delegate.DelegateExecution;
1113
import org.camunda.bpm.engine.variable.Variables;
1214
import org.highmed.dsf.bpe.delegate.AbstractServiceDelegate;
@@ -20,14 +22,14 @@
2022
import org.slf4j.Logger;
2123
import org.slf4j.LoggerFactory;
2224

23-
public class StartTimer extends AbstractServiceDelegate
25+
public class SetTargetAndConfigureTimer extends AbstractServiceDelegate
2426
{
25-
private static final Logger logger = LoggerFactory.getLogger(StartTimer.class);
27+
private static final Logger logger = LoggerFactory.getLogger(SetTargetAndConfigureTimer.class);
2628

2729
private final OrganizationProvider organizationProvider;
2830
private final EndpointProvider endpointProvider;
2931

30-
public StartTimer(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper,
32+
public SetTargetAndConfigureTimer(FhirWebserviceClientProvider clientProvider, TaskHelper taskHelper,
3133
ReadAccessHelper readAccessHelper, OrganizationProvider organizationProvider,
3234
EndpointProvider endpointProvider)
3335
{
@@ -38,11 +40,17 @@ public StartTimer(FhirWebserviceClientProvider clientProvider, TaskHelper taskHe
3840
}
3941

4042
@Override
41-
protected void doExecute(DelegateExecution execution) throws Exception
43+
public void afterPropertiesSet() throws Exception
4244
{
43-
logger.debug("Setting variable '{}' to false", BPMN_EXECUTION_VARIABLE_STOP_TIMER);
44-
execution.setVariable(BPMN_EXECUTION_VARIABLE_STOP_TIMER, Variables.booleanValue(false));
45+
super.afterPropertiesSet();
46+
47+
Objects.requireNonNull(organizationProvider, "organizationProvider");
48+
Objects.requireNonNull(endpointProvider, "endpointProvider");
49+
}
4550

51+
@Override
52+
protected void doExecute(DelegateExecution execution) throws BpmnError, Exception
53+
{
4654
String timerInterval = getTimerInterval(execution);
4755
logger.debug("Setting variable '{}' to {}", BPMN_EXECUTION_VARIABLE_TIMER_INTERVAL, timerInterval);
4856
execution.setVariable(BPMN_EXECUTION_VARIABLE_TIMER_INTERVAL, Variables.stringValue(timerInterval));

dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/service/StopTimer.java

Lines changed: 0 additions & 30 deletions
This file was deleted.

dsf-bpe-process-ping/src/main/java/org/highmed/dsf/bpe/spring/config/PingConfig.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
import org.highmed.dsf.bpe.service.LogPong;
1010
import org.highmed.dsf.bpe.service.SelectPingTargets;
1111
import org.highmed.dsf.bpe.service.SelectPongTarget;
12-
import org.highmed.dsf.bpe.service.StartTimer;
13-
import org.highmed.dsf.bpe.service.StopTimer;
12+
import org.highmed.dsf.bpe.service.SetTargetAndConfigureTimer;
1413
import org.highmed.dsf.bpe.util.PingStatusGenerator;
1514
import org.highmed.dsf.fhir.authorization.read.ReadAccessHelper;
1615
import org.highmed.dsf.fhir.client.FhirWebserviceClientProvider;
@@ -45,9 +44,10 @@ public class PingConfig
4544
private FhirContext fhirContext;
4645

4746
@Bean
48-
public StartTimer startTimer()
47+
public SetTargetAndConfigureTimer setTargetAndConfigureTimer()
4948
{
50-
return new StartTimer(clientProvider, taskHelper, readAccessHelper, organizationProvider, endpointProvider);
49+
return new SetTargetAndConfigureTimer(clientProvider, taskHelper, readAccessHelper, organizationProvider,
50+
endpointProvider);
5151
}
5252

5353
@Bean
@@ -56,12 +56,6 @@ public SendStartPing sendStartPing()
5656
return new SendStartPing(clientProvider, taskHelper, readAccessHelper, organizationProvider, fhirContext);
5757
}
5858

59-
@Bean
60-
public StopTimer stopTimer()
61-
{
62-
return new StopTimer(clientProvider, taskHelper, readAccessHelper);
63-
}
64-
6559
@Bean
6660
public PingStatusGenerator responseGenerator()
6761
{

0 commit comments

Comments
 (0)