문제

There is a situation where I want to invoke a method after some predetermined time, say 30 sec or 5 min.

Time needs to be configured at run time, means I should be able to change time dynamically from 5 min to 3 min.(reset the timer to new interval programmatically)

I am developing a dynamic web project using Spring framework.

I have checked the Quartz and Timer classes but they seem to read XML configuration for parameters such as delay, repeatInterval and so on.

How can I do that? Does Spring provide any support for this?

Thank you in advance.

도움이 되었습니까?

해결책

The easiest way is to configure and inject an instance of something that implements Spring's TaskScheduler interface (e.g. ThreadPoolTaskExecutor). This provides various methods to schedule tasks for delayed execution.

Quartz is overkill for this.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top