Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scheduled Rate from property file

Hi i like to take the scheduler value from property file , my spring version is 3.1.2 . I cant update the version of spring . fixedRateString is only available in higher version 3.2.2 . Is there any way i can get this value from property file.

@Scheduled(fixedRate = 1000000)
like image 755
VKP Avatar asked Sep 06 '25 13:09

VKP


1 Answers

You can use @Scheduled(cron=". . .") expressions for task scheduling.

If a fixed rate execution is desired, simply change the property name specified within the annotation. The following would be executed every 5 seconds measured between the successive start times of each invocation.

@Scheduled(fixedRate=5000)
public void doSomething() {
    // something that should execute periodically
}

If simple periodic scheduling is not expressive enough, then a cron expression may be provided. For example, the following will only execute on weekdays.

@Scheduled(cron="*/5 * * * * MON-FRI")
public void doSomething() {
    // something that should execute on weekdays only
}

spring/docs/3.1.x/spring-framework-reference/html/scheduling.html

cron-expression

like image 113
0gam Avatar answered Sep 08 '25 04:09

0gam