create sharepoint work item timer jobs
DESCRIPTION
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.TRANSCRIPT
Work Item Timer JobsSuhail Jamaldeenhttp://jsuhail.blogspot.com
@jsuhail
Agenda
Introduction to SharePoint Timer Jobs
Introduction to Custom Timer Jobs
Regular Timer Jobs
Work Item Timer Jobs – A Scenario
Regular Timer Jobs Vs Work Item Timer Jobs
Work Item Timer Jobs in depth
Demo
Q & A
Timer Jobs
Used to run background tasks that do not require user interactions
Runs on a schedule basis
Runs on separate process – SharePoint Timer 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
Custom Timer 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 SharePoint Online
Two types of timer jobs Regular timer job Work item timer jobs
Work Item Timer Job Scenario
Add User Group
User Group + Users
Add to Queue
Access Active Directory
Process Queue
Save to Database
Work Item Timer Job
Regular Timer Job Vs Work Item Timer Job
Regular Timer Job Work Item Timer 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
Work Item Timer Jobs
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
Work Item Timer Jobs
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.
How to create a Work Item Timer Jobs
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
DEMO
Q & A
Thank You@jsuhail
http://jsuhail.blogspot.com