Work Item Timer Jobs are a special type of timer jobs specifically designed to process a set of items. A work item timer job works by processing items in a queue.
2. Agenda
Introduction to SharePointTimer Jobs
Introduction to CustomTimer Jobs
RegularTimer Jobs
Work ItemTimer Jobs – A Scenario
RegularTimer JobsVsWork ItemTimer Jobs
Work ItemTimer Jobs in depth
Demo
Q & A
3. TimerJobs
Used to run background tasks that do not require user interactions
Runs on a schedule basis
Runs on separate process – SharePointTimer Service /
owstimer.exe
Owstimer.exe runs under farm service account –This gives
permission to access both content and configuration database
Build in default timer jobs
More than 100
Workflow timer jobs
Audit log timer jobs
Processing health and diagnosis
Applying expiration policies
Alerts
4. CustomTimer
Jobs
When to create custom timer jobs
Long running process
Which not required user input
Process tasks which doesn’t need to return information user
Can be deployed in on premises environment
Cannot deployed in SharePointOnline
Two types of timer jobs
Regular timer job
Work item timer jobs
5. Work Item
TimerJob
Scenario
Add User Group
User Group + Users
Add to Queue
AccessActive Directory
ProcessQueue
Save to Database
Work ItemTimer Job
6. RegularTimer
JobVsWork
ItemTimerJob
RegularTimer Job Work ItemTimer Job
Inherits from SPJobDefinition SPWorkItemJobDefinition
Logics in – Execute Method ProcessWorkItem
Limits should be implement by the
developers
BatchFetchLimit to limit the data to
process
No items added in queues Items added in queues
Use FeatureActivated method to create a Job
Can be scheduled as needed
7. Work Item
TimerJobs
Special type of timer job specifically designed to process a set of
items
Add items to the queue
Stored in dbo.ScheduledWorkItems table in content database
8. Work Item
TimerJobs
Then the items in the queue will be processed
You should delete the work item after you run your code against it,
unless of course you want the item to be processed every time the
timer job runs.
Execute the timer job logics if at least one work item has been
added to the queue
The user, adding the work items must be a site collection
administrator or use elevated privileges.
9. How to create
aWork Item
TimerJobs
Create a class that inherits from SPWorkItemJobDefinition
Override the WorkItemType property with a unique Guid
Override the ProcessWorkItem method.This is where the logics takes
place. Same as the Execute method in Regular timer job
Create a new work item for a site collection. For that call the method
SPSite.AddWorkItem