diff options
author | grabinsk <maciej.grabinski@nokia.com> | 2019-06-14 13:50:16 +0200 |
---|---|---|
committer | grabinsk <maciej.grabinski@nokia.com> | 2019-06-14 13:50:16 +0200 |
commit | b494ec44ddd26a516e36d69cbbf06f1214d37825 (patch) | |
tree | 19254c557c9ce29d69bb3da71446f6a9666c2d58 /prh-app-server/src/main | |
parent | 4117c9fd7fcea895e18872e0d541e0f14a9a41b9 (diff) |
Do not start scheduling until application starts
(moving task schedule starting logic from bean's post construct to ApplicationStartedEvent listener)
Change-Id: Ia09ecbf5efda9b8f838053359bba2cfe80ce095b
Issue-ID: DCAEGEN2-1544
Signed-off-by: grabinsk <maciej.grabinski@nokia.com>
Diffstat (limited to 'prh-app-server/src/main')
-rw-r--r-- | prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasksRunner.java | 9 |
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()) { |