diff --git a/cloudslang-runtime/pom.xml b/cloudslang-runtime/pom.xml
index 555e18cd7..b52b93e9c 100644
--- a/cloudslang-runtime/pom.xml
+++ b/cloudslang-runtime/pom.xml
@@ -154,6 +154,10 @@
${parent.version}
+
+ ${score.group}
+ score-worker-manager-api
+
diff --git a/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/steps/ExecutableExecutionData.java b/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/steps/ExecutableExecutionData.java
index 05492922b..a30f15c6e 100644
--- a/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/steps/ExecutableExecutionData.java
+++ b/cloudslang-runtime/src/main/java/io/cloudslang/lang/runtime/steps/ExecutableExecutionData.java
@@ -30,14 +30,17 @@
import io.cloudslang.lang.runtime.env.RunEnvironment;
import io.cloudslang.lang.runtime.events.LanguageEventData;
import io.cloudslang.score.api.execution.precondition.ExecutionPreconditionService;
+import io.cloudslang.score.facade.execution.ExecutionStatus;
import io.cloudslang.score.lang.ExecutionRuntimeServices;
import io.cloudslang.score.lang.SystemContext;
+import io.cloudslang.worker.management.WorkerConfigurationService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.util.Strings;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.Serializable;
@@ -85,6 +88,9 @@ public class ExecutableExecutionData extends AbstractExecutionData {
private final DebuggerBreakpointsHandler debuggerBreakpointsHandler;
private final ArgumentsBinding argumentsBinding;
+ @Autowired(required = false)
+ private WorkerConfigurationService workerConfigurationService;
+
public ExecutableExecutionData(ResultsBinding resultsBinding, InputsBinding inputsBinding,
OutputsBinding outputsBinding, ExecutionPreconditionService preconditionService,
MissingInputHandler missingInputHandler,
@@ -387,6 +393,16 @@ public void canExecute(@Param(ScoreLangConstants.RUN_ENV) RunEnvironment runEnv,
@Param(ScoreLangConstants.NODE_NAME_KEY) String nodeName,
@Param(ScoreLangConstants.NEXT_STEP_ID_KEY) Long nextStepId) {
try {
+ // check canceled, if it is then set next position to null and flow termination type
+ if (workerConfigurationService != null &&
+ (workerConfigurationService.isExecutionCancelled(executionRuntimeServices.getExecutionId()) ||
+ (executionRuntimeServices.getFlowTerminationType() == ExecutionStatus.CANCELED))) {
+ // NOTE: an execution can be cancelled directly from CancelExecutionService, if it's currently paused.
+ // Thus, if you change the code here, please check CancelExecutionService as well.
+ executionRuntimeServices.setFlowTerminationType(ExecutionStatus.CANCELED);
+ runEnv.putNextStepPosition(null);
+ return;
+ }
if (!isEmpty(runEnv.getExecutionPath().getParentPath())) {
// If it is start of a sub flow then the check should not happen
runEnv.putNextStepPosition(nextStepId);
diff --git a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/ExecutableStepsTest.java b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/ExecutableStepsTest.java
index c65178876..2a2f32b96 100644
--- a/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/ExecutableStepsTest.java
+++ b/cloudslang-runtime/src/test/java/io/cloudslang/lang/runtime/steps/ExecutableStepsTest.java
@@ -60,6 +60,7 @@
import io.cloudslang.score.events.ScoreEvent;
import io.cloudslang.score.lang.ExecutionRuntimeServices;
import io.cloudslang.score.lang.SystemContext;
+import io.cloudslang.worker.management.WorkerConfigurationService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@@ -481,6 +482,11 @@ public ArgumentsBinding argumentsBinding() {
return new ArgumentsBinding();
}
+ @Bean
+ public WorkerConfigurationService getWorkerConfigurationService() {
+ return mock(WorkerConfigurationService.class);
+ }
+
@Bean
public ExecutionPreconditionService executionPreconditionService() {
return mock(ExecutionPreconditionService.class);
diff --git a/pom.xml b/pom.xml
index 47391efbf..e1d633853 100644
--- a/pom.xml
+++ b/pom.xml
@@ -172,6 +172,12 @@
score-api
${score.version}
+
+
+ ${score.group}
+ score-worker-manager-api
+ ${score.version}
+
${score.group}