summaryrefslogtreecommitdiffstats
path: root/prh-app-server
diff options
context:
space:
mode:
authorPiotr Wielebski <piotr.wielebski@nokia.com>2019-06-17 12:50:33 +0000
committerGerrit Code Review <gerrit@onap.org>2019-06-17 12:50:33 +0000
commita7d645115b7b518fa1ac9eb8edd63f08b267f9eb (patch)
tree3ae8131cb772ccc1ba8d625cf1fa021c472246e3 /prh-app-server
parent97c7eb3f95a09aaa882a5a4f5d57b5c6668cdf10 (diff)
parentb494ec44ddd26a516e36d69cbbf06f1214d37825 (diff)
Merge "Do not start scheduling until application starts"
Diffstat (limited to 'prh-app-server')
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasksRunner.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasksRunner.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasksRunner.java
index c3eaa12f..25ed262e 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasksRunner.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasksRunner.java
@@ -24,13 +24,14 @@ import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ScheduledFuture;
-import javax.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.Marker;
import org.slf4j.MarkerFactory;
+import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.annotation.Configuration;
+import org.springframework.context.event.EventListener;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.annotation.EnableScheduling;
@@ -54,6 +55,11 @@ public class ScheduledTasksRunner {
this.scheduledTask = scheduledTask;
}
+ @EventListener
+ public void onApplicationStartedEvent(ApplicationStartedEvent applicationStartedEvent) {
+ tryToStartTask();
+ }
+
/**
* Function which have to stop tasks execution.
*/
@@ -67,7 +73,6 @@ public class ScheduledTasksRunner {
*
* @return status of operation execution: true - started, false - not started
*/
- @PostConstruct
public synchronized boolean tryToStartTask() {
LOGGER.info(ENTRY, "Start scheduling PRH workflow");
if (scheduledPrhTaskFutureList.isEmpty()) {