Sunday, 4 September 2016

Spring Scheduler Example

Requirement to perform some action at end of day - that would be used within the application , since this was better to map our application structure , we used spring scheduler to do this task.


 xmlns:task="http://www.springframework.org/schema/task"
 http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd" 
 Add the above schema definition to your parent bean. 
 Below annotation in to register you anotated class.
 
 task:annotation-driven (Please add <>)

 And Finally your method to execute with the cron parameter for execution trigger details
  
   //* "0 0 * * * *" = the top of every hour of every day.
   //* "*/10 * * * * *" = every ten seconds.
   //* "0 0 8-10 * * *" = 8, 9 and 10 o'clock of every day.
   //* "0 0/30 8-10 * * *" = 8:00, 8:30, 9:00, 9:30 and 10 o'clock every day.
   //* "0 0 9-17 * * MON-FRI" = on the hour nine-to-five weekdays
   //* "0 0 0 25 12 ?" = every Christmas Day at midnight
 
 
   +-------------------- second (0 - 59)
   |  +----------------- minute (0 - 59)
   |  |  +-------------- hour (0 - 23)
   |  |  |  +----------- day of month (1 - 31)
   |  |  |  |  +-------- month (1 - 12)
   |  |  |  |  |  +----- day of week (0 - 6) (Sunday=0 or 7)
   |  |  |  |  |  |  +-- year [optional]
   |  |  |  |  |  |  |
   *  *  *  *  *  *  * command to be executed 
 
   @Scheduled(cron = "*/10 * * * * *")
   public void demoServiceMethod()

       

No comments:

Post a Comment

AWS Certificate Manager - Import Certificate

How to import a certificate. Use Key Store Explorer to open the cert and export keypair in PEM format  This will save a file cert.pem. Make ...