'Apply Spring task-scheduler to multiple instances of same Bean using Annotation
I have one class Task with a @Scheduled method as below
public class Task{
public void task(){}
}
TaskConfig creates 2 different beans of same class :
public class TaskConfig{
@Bean("task1")
public Task getTask1(){return new Task();}
@Bean("task2")
public Task getTask1(){return new Task();}
}
Using xml based configuration I can create 2 scheduler for same method as below, which will run at differenct time. :
<task:scheduled-tasks >
<task:scheduled ref="task1" method="task" cron="*/5 * * * * ?" />
<task:scheduled ref="task2" method="task" cron="*/30 * * * * ?" />
</task:scheduled-tasks>
But how to achieve this same scenario in Spring 5 Annotation based ? Please suggest.Thanks in advance !
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
