Skip to content

Commit 6ecad6d

Browse files
committed
Enable scheduling for spring-boot application
1 parent 0301bba commit 6ecad6d

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/main/java/org/commonwl/view/CwlViewerApplication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@
2323
import org.springframework.boot.autoconfigure.SpringBootApplication;
2424
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
2525
import org.springframework.scheduling.annotation.EnableAsync;
26+
import org.springframework.scheduling.annotation.EnableScheduling;
2627

2728
@SpringBootApplication
2829
@EnableMongoRepositories
2930
@EnableAsync
31+
@EnableScheduling
3032
public class CwlViewerApplication {
3133

3234
public static void main(String[] args) {
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package org.commonwl.view.workflow;
2+
3+
4+
import org.springframework.beans.factory.annotation.Autowired;
5+
import org.springframework.scheduling.annotation.Scheduled;
6+
import org.springframework.stereotype.Component;
7+
8+
import java.util.Date;
9+
10+
@Component
11+
public class Scheduler {
12+
13+
private final QueuedWorkflowRepository queuedWorkflowRepository;
14+
15+
@Autowired
16+
public Scheduler(QueuedWorkflowRepository queuedWorkflowRepository) {
17+
this.queuedWorkflowRepository = queuedWorkflowRepository;
18+
}
19+
20+
@Scheduled(cron = "* * * * * ?")
21+
public void removeOldQueuedWorkflowEntries() {
22+
Date now = new Date();
23+
System.out.println("The time is " + now);
24+
System.out.println("The repository is " + queuedWorkflowRepository.toString());
25+
}
26+
}

0 commit comments

Comments
 (0)