Monday, June 14, 2010

Spring 3: Scheduling... Take 2

In the previous blog entry I used Spring annotation scheduling to fire an event, but there is also another way through the application context xml.

Annotation:
In the application context.




Then within the code annotate the method with @Scheduled(fixedDelay = 10000)

XML:
Now if you annotate your class with @Service or @Component (with component-scan), you can use the scheduled-tasks tag, and schedule a method on a service and specify a cron expression, which does give you all the control you'll need.




    



Since I personally can never remember the exact format for cron I am adding the next little bit for easy reference.

* * * * * *
| | | | | |
| | | | | +-- Year (range: 1900-3000)
| | | | +---- Day of the Week (range: 1-7, 1 standing for Monday)
| | | +------ Month of the Year (range: 1-12)
| | +-------- Day of the Month (range: 1-31)
| +---------- Hour (range: 0-23)
+------------ Minute (range: 0-59)


0 23 * * 1-5 * At 11:00PM on weekdays Mon-Fri
0 0 1 * * * At midnight, on the first day of each month
* * * * * ? Every Second
0 * * * * ? Every Minute

2 comments:

  1. https://www.oobbg.com 우리카지노사이트
    https://www.oobbg.com/theking 더킹카지노
    https://www.oobbg.com/sands 샌즈카지노
    https://www.oobbg.com/first 퍼스트카지노
    https://www.oobbg.com/yes 예스카지노
    https://www.oobbg.com/coin 코인카지노
    https://www.oobbg.com/33 33카지노
    https://www.oobbg.com/world 월드카지노
    https://www.oobbg.com/merit 메리트카지노
    https://www.oobbg.com/gatsby 개츠비카지노

    ReplyDelete

Popular Posts

Followers