SharePoint 2010 timer job has many good improvements. I had a chance to look at all those good features and also implemented in my current project. Lets discuss and see what are new improvements and how you can leverage those new features.
- Brief About Timer Jobs
Timer jobs are very useful when you want to run some processes in background on regular interval.
- SpJobDefinition Class
In SharePoint 2010’s timer job has some major enhancements.
- IBackupRestore Implementation
SPJobDefinition now can be backed up. The IBackupRestore interface contains methods that you can override and implement to perform actions before and after restores and backups of the timer job.
- UpdateProgress Method
Another great addition is that all timer jobs now have a Progress value (ranging from 0 to 100) which you can set by calling the UpdateProgress(int) method. Awesome for long running timer jobs and the progress is shown in Central Administration.
Now Job can be run one time by RunNow() method. Job is run immediately.
New Classes to support more granular Access like List and List Item or different types of jobs
SPAllSitesJobDefinition – A Job Designed to be used at Site collection Level
This class is very useful when you want to build functionality around SPSite object. For Example you want to Trigger workflow on List items/ Update List Item.
This class is inherited from SPContentDatabaseJobDefinition. The ProcessSiteMethod , we can override to process SPSite.
- SPContentDatabaseJobDefinition– A Job Designed to be used to perform action at Content Database.
If you develop job by inheriting SPContentDatabaseJobDefinition, you can perform action on Content Database.
One Job can only be run on one Content Database. Execute(SpContentDatbase, SpJobState), which you can override to implement your custom logic.
- SPServerJobDefinition – Server Specific job target to specific server on a FARM.
- SPServiceJobDefinition- Service specific job target ona particular Service on a Server
- SPPausableJobDefinition- you can develop pause able timer job by inheriting SPPausableJobDefinition.
Overall these all are major and important enhancements. This new feature will save your lot of development time.