create sharepoint work item timer jobs

12
Work Item Timer Jobs Suhail Jamaldeen http://jsuhail.blogspot.com @jsuhail

Upload: suhail-jamaldeen

Post on 24-May-2015

634 views

Category:

Software


4 download

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

Page 1: Create SharePoint Work Item Timer Jobs

Work Item Timer JobsSuhail Jamaldeenhttp://jsuhail.blogspot.com

@jsuhail

Page 2: Create SharePoint Work Item Timer Jobs

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

Page 3: Create SharePoint Work Item Timer Jobs

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

Page 4: Create SharePoint Work Item Timer Jobs

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

Page 5: Create SharePoint 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

Page 6: Create SharePoint Work Item Timer Jobs

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

Page 7: Create SharePoint Work Item Timer Jobs

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

Page 8: Create SharePoint Work Item Timer Jobs

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.

Page 9: Create SharePoint Work Item Timer Jobs

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

Page 10: Create SharePoint Work Item Timer Jobs

DEMO

Page 11: Create SharePoint Work Item Timer Jobs

Q & A

Page 12: Create SharePoint Work Item Timer Jobs

Thank You@jsuhail

http://jsuhail.blogspot.com