Reputation: 19434
PingInvoker.java
@Service
public class PingInvoker
{
@Scheduled(fixedRate = 5000) //<--how can I make this changeable while server is up and running
public void ping()
{
List<Server> svr = Manager.geList();
System.out.println("Invoking " + svr.size() + " Ping(s)");
for (Server i : svr)
i.ping();
}
}
Upvotes: 1
Views: 2165
Reputation: 403451
The scheduler annotations are just a lightweight convenience for the simplest use cases. If you need access to more flexibility, such as runtime re-scheduling of tasks, then you need to use a different technique.
In your case, it should be sufficient to @Autowire
a TaskScheduler
field in your class, which you can then use to dynamically schedule your tasks. See the Spring docs for more info.
Upvotes: 3