SlideShare ist ein Scribd-Unternehmen logo
1 von 39
Downloaden Sie, um offline zu lesen
#SPSNJ @PGBhoyar
Presented By: Prashant G Bhoyar
Building Solutions using
SharePoint Timer Jobs
05 October 2013
#SPSNJ @PGBhoyar
Who am I?
• SharePoint Consultant at Portal
Solutions
• Product - AuthentiMate
• Services – We love SharePoint ..
• Guy with multiple hats
• University of Maryland College
Park Alumni
• Recipient of Antarctic Service
Medal
#SPSNJ @PGBhoyar
What Will We Cover Today?
• What are Timer Jobs?
• Common business scenarios for Timer Jobs
• Timer Job architecture
• Developing Timer Jobs
• Various approaches to registering Timer Jobs
• How to Test/Debug Timer Jobs
• Common issues and fixes for Timer Jobs
• Timer Jobs best practices
• When not to use them
#SPSNJ @PGBhoyar
#SPSNJ @PGBhoyar
What are Timer Jobs?
• Perform much of backend work to maintain farm
• Run on one or more server at scheduled time
• Run periodically and independent of the users
• Offload long running processes from web front end server
• Run code under higher privileges
#SPSNJ @PGBhoyar
What are Timer Jobs?
• To Summarize,
#SPSNJ @PGBhoyar
Examples of Timer Jobs in
SharePoint
• Clean up Old Sites
• User Profile Sync
• Solution Deployment
• Search Index
• Various other Automations/Long Running operations
#SPSNJ @PGBhoyar
#SPSNJ @PGBhoyar
LessComplexity
Timer Jobs Vs Scheduled Tasks
Scheduled Tasks Timer Jobs
-Create Console App
-Schedule it using Windows Tasks Scheduler
-Easy to setup
-Create Custom Timer Job
-Register in SharePoint
-No reporting available
-Need to implement custom logging
-Can track status, history, change the schedule,
start/stop using Central Admin.
-Need direct access to SharePoint Servers (Not
easy to get)
-Request special account to run the Scheduled
Tasks
-Timer Job runs under SharePoint Timer Job
Account
-Load Balancing is not available -Load balancing is available
-Console Application -Full Access to SharePoint API (SPSite,
SPWebApplication)
#SPSNJ @PGBhoyar
Timer Jobs in SharePoint Farm
• Central Admin -> Monitoring ->Review Job Definitions
#SPSNJ @PGBhoyar
Timer Jobs in SharePoint Farm
• Windows SharePoint Services Timer Service(SPTimerV4) run Timer Job
• Service must be enabled and running in each server
• Start –Administrative Tools -> Services
• The timer job executes under OWSTIMER.exe
#SPSNJ @PGBhoyar
#SPSNJ @PGBhoyar
Create Custom Timer Jobs
• Visual Studio -> Empty SharePoint Project
• Deploy as Farm Solution
#SPSNJ @PGBhoyar
LessComplexity
Architecture of Timer Jobs
• Microsoft.SharePoint.Administration.SPJobDefinition :
Timer Jobs are created and executed by using this class
• Three Constructors
• Default (No Parameters):
• For internal use
• Others :
• Job Name
• Job Lock Type
• Web Application or Service
#SPSNJ @PGBhoyar
LessComplexity
Architecture of Timer Jobs
• Parameters of SPJobDefinition Constructor
Name Description
Name Name of the Job
Service An instance of the SPService class that owns this job
WebApplication Parent WebApplication
Server An instance of the SPServer class associated with this job
lockType An SPJobLockType value that indicates the circumstances under which
multiple instances of the job can be run simultaneously.
http://msdn.microsoft.com/en-us/library/hh528519(v=office.14).aspx
#SPSNJ @PGBhoyar
LessComplexity
Architecture of Timer Jobs
• SPJobLockType values
Value Description
None No locks. The timer job runs on every machine on which the
parent service is provisioned.
ContentDatabase Job runs for each content database associated with the job's web
application.
Job Only one server can run the job at a time.
#SPSNJ @PGBhoyar
LessComplexity
Architecture of Timer Jobs
• Override the Execute method of the SPJobDefinition class and
replace the code in that method with the code that your job
requires.
• The targetInstanceId maps to the Guid of the Current content
database while the timer job is running
#SPSNJ @PGBhoyar
#SPSNJ @PGBhoyar
Typical Timer Job Life Cycle
#SPSNJ @PGBhoyar
#SPSNJ @PGBhoyar
LessComplexity
Two options:
• Declarative by using SharePoint Feature
• Pros: Easy to deploy and maintain
• Cons: Difficult to develop
• Programmatically using Server side object model
• Pros : Flexible, Easier to Develop
• Cons : Difficult to deploy and maintain
Deployment and Registration of
Custom Timer Jobs
#SPSNJ @PGBhoyar
LessComplexity
Option 01 : Declarative by using SharePoint
Feature
• Add Feature
• Add code to register
Timer Job in the
FeatureActivated
• Add code to delete
Timer Job in the
FeatureDeActivating
Deployment and Registration of
Custom Timer Jobs
#SPSNJ @PGBhoyar
LessComplexity
Option 02 : Programmatically using Server side object model
• Create Console Application/Power Shell Script
• Add code to register Timer Job
• Add code to delete Timer Job
Deployment and Registration of
Custom Timer Jobs
#SPSNJ @PGBhoyar
#SPSNJ @PGBhoyar
LessComplexity
• Attach the debugger to “OWSTIMER.EXE”
• Debug -> Attach to Process
Debug Custom Timer Jobs
#SPSNJ @PGBhoyar
LessComplexity
• Check the History To see when the timer job ran last time
Debug Custom Timer Jobs
#SPSNJ @PGBhoyar
#SPSNJ @PGBhoyar
LessComplexity
• Change the Schedule using Central Admin
• Change the Schedule using PowerShell Commands
• $timerJob = Get-SPTimerJob -Identity "SPSDC2013
TimerJob01"
• Start-SPTimerJob $timerJob
• Easiest : Write Console Application to debug business logic
Expedite Debugging
#SPSNJ @PGBhoyar
DEMO
#SPSNJ @PGBhoyar
LessComplexity
Developing Custom Timer Jobs
• Set up the solution
• Add a class and Inherit from SPJobDefinition
• Override Execute Method
• Register Timer Jobs
#SPSNJ @PGBhoyar
#SPSNJ @PGBhoyar
Common Issues and Fixes
• Redeployment : IISRESET and ReStart Timer Services
• Debugging takes lot of time :
• Use Console Application to debug the business login during
development
• Always implement Exception Handling
• SPContext is NOT AVAILABLE. Never use it in Timer Jobs.
• If you use SiteCollection Feature to register timer job,
activate/deactivate using PowerShell
• If SPJobLockType is set to ContentDatabase, timer job will get
fired multiple times depending on number of Content Databases
#SPSNJ @PGBhoyar
Best Practices
• Always implement Exception Handling
• SPContext is NOT AVAILABLE. Never use it in Timer Jobs.
• In production restart the Timer Services using command
• “Get-SPTimerJob job-timer-recycle | Start-SPTimerJob”
• Use Console Application to debug the business login during
development
#SPSNJ @PGBhoyar
When not to use Timer Jobs?
• OOTB Options are available
• Content/Data needs to be updated synchronously
• Simple data processing that can be easily handled with Event
Receivers
#SPSNJ @PGBhoyar
Outcome
#SPSNJ @PGBhoyar
References
Appendix/Resources
MSDN:
http://msdn.microsoft.com/en-us/library/hh528519(v=office.14).aspx
http://technet.microsoft.com/en-us/library/cc678870(v=office.12).aspx
http://www.andrewconnell.com/Creating-Custom-SharePoint-Timer-Jobs
http://msdn.microsoft.com/en-us/library/cc406686.aspx
#SPSNJ @PGBhoyar
Princeton SharePoint user group
• Different SharePoint
discussions each month on
various topics. Announced on
meetup.com
• Meets 4th Wednesday of every
month
• 6pm – 8pm
• Infragistics Office
• 2 Commerce Drive, Cranbury,
NJ
• http://www.meetup.com/prin
cetonSUG
• http://www.princetonsug.com
#SPSNJ @PGBhoyar
Thank You Event Sponsors
• Platinum & Gold
sponsors have
tables here in the
Fireside Lounge
• Please visit them
and inquire
about their
products &
services
• To be eligible for
prizes make sure
your bingo card is
signed by all
Platinum/Gold
#SPSNJ @PGBhoyar
Questions? Feedback? Contact me:
 Twitter: @PGBhoyar
 Blog: http://pgbhoyar.wordpress.com (limited contents)
 Email: pgbhoyar@gmail.com
Thank You
Organizers, Sponsors and You for Making this
Possible.

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

SharePoint Saturday San Antonio: Workflow 2013
SharePoint Saturday San Antonio: Workflow 2013SharePoint Saturday San Antonio: Workflow 2013
SharePoint Saturday San Antonio: Workflow 2013
 
Using Chat Automation - ChatOps
Using Chat Automation - ChatOpsUsing Chat Automation - ChatOps
Using Chat Automation - ChatOps
 
Do's and don'ts for Office 365 development
Do's and don'ts for Office 365 developmentDo's and don'ts for Office 365 development
Do's and don'ts for Office 365 development
 
O365con14 - sharepoint online applification
O365con14 - sharepoint online applificationO365con14 - sharepoint online applification
O365con14 - sharepoint online applification
 
ECS19 - Thomas Vochten - ESSENTIAL DATABASE ADMINISTRATION SKILLS FOR SHAREPO...
ECS19 - Thomas Vochten - ESSENTIAL DATABASE ADMINISTRATION SKILLS FOR SHAREPO...ECS19 - Thomas Vochten - ESSENTIAL DATABASE ADMINISTRATION SKILLS FOR SHAREPO...
ECS19 - Thomas Vochten - ESSENTIAL DATABASE ADMINISTRATION SKILLS FOR SHAREPO...
 
SharePoint Framework - Developer Preview
SharePoint Framework - Developer PreviewSharePoint Framework - Developer Preview
SharePoint Framework - Developer Preview
 
Spring insight what just happened
Spring insight   what just happenedSpring insight   what just happened
Spring insight what just happened
 
Creating SharePoint 2013 Workflows
Creating SharePoint 2013 WorkflowsCreating SharePoint 2013 Workflows
Creating SharePoint 2013 Workflows
 
O365Con18 - SharePoint Framework for Administrators - Waldek Mastykarz
O365Con18 - SharePoint Framework for Administrators - Waldek MastykarzO365Con18 - SharePoint Framework for Administrators - Waldek Mastykarz
O365Con18 - SharePoint Framework for Administrators - Waldek Mastykarz
 
Value of share point add ins
Value of share point add insValue of share point add ins
Value of share point add ins
 
#SPSBrussels 2017 vincent biret #azure #functions microsoft #flow
#SPSBrussels 2017 vincent biret #azure #functions microsoft #flow#SPSBrussels 2017 vincent biret #azure #functions microsoft #flow
#SPSBrussels 2017 vincent biret #azure #functions microsoft #flow
 
O365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
O365Con18 - Automate your Tasks through Azure Functions - Elio StruyfO365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
O365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
 
Custom Development in SharePoint – What are my options now?
Custom Development in SharePoint – What are my options now?Custom Development in SharePoint – What are my options now?
Custom Development in SharePoint – What are my options now?
 
Automate it with Azure Functions
Automate it with Azure FunctionsAutomate it with Azure Functions
Automate it with Azure Functions
 
Introduction to Office 365 PnP- Reusable solutions
Introduction to Office 365 PnP- Reusable solutionsIntroduction to Office 365 PnP- Reusable solutions
Introduction to Office 365 PnP- Reusable solutions
 
JavaScript and jQuery for SharePoint Developers
JavaScript and jQuery for SharePoint DevelopersJavaScript and jQuery for SharePoint Developers
JavaScript and jQuery for SharePoint Developers
 
Exchange Integration in 5.0, by Doug Johnson
Exchange Integration in 5.0, by Doug JohnsonExchange Integration in 5.0, by Doug Johnson
Exchange Integration in 5.0, by Doug Johnson
 
ASP.NET 5 & Unit Testing
ASP.NET 5 & Unit TestingASP.NET 5 & Unit Testing
ASP.NET 5 & Unit Testing
 
Essential Knowledge for SharePoint Add-Ins
Essential Knowledge for SharePoint Add-InsEssential Knowledge for SharePoint Add-Ins
Essential Knowledge for SharePoint Add-Ins
 
SharePoint 2010 Workflows
SharePoint 2010 WorkflowsSharePoint 2010 Workflows
SharePoint 2010 Workflows
 

Ähnlich wie SPSNJ 2013 Building Solutions using SharePoint TimerJobs

Ähnlich wie SPSNJ 2013 Building Solutions using SharePoint TimerJobs (20)

Writing Futuristic Workflows in Office 365 SharePoint 2013 2016 on premise
Writing Futuristic Workflows in Office 365 SharePoint 2013 2016 on premiseWriting Futuristic Workflows in Office 365 SharePoint 2013 2016 on premise
Writing Futuristic Workflows in Office 365 SharePoint 2013 2016 on premise
 
Getting started with content deployment in SharePoint 2013 SPFestDC 2015
Getting started with content deployment in SharePoint 2013 SPFestDC 2015Getting started with content deployment in SharePoint 2013 SPFestDC 2015
Getting started with content deployment in SharePoint 2013 SPFestDC 2015
 
Azure Functions in Action #CodePaLOUsa
Azure Functions in Action #CodePaLOUsaAzure Functions in Action #CodePaLOUsa
Azure Functions in Action #CodePaLOUsa
 
Nsc 2013 06-17 - random rants on 2013
Nsc 2013 06-17 - random rants on 2013Nsc 2013 06-17 - random rants on 2013
Nsc 2013 06-17 - random rants on 2013
 
Era of server less computing final
Era of server less computing finalEra of server less computing final
Era of server less computing final
 
Building Business Applications in Office 365 SharePoint Online Using Logic Apps
Building Business Applications in Office 365 SharePoint Online Using Logic AppsBuilding Business Applications in Office 365 SharePoint Online Using Logic Apps
Building Business Applications in Office 365 SharePoint Online Using Logic Apps
 
SPSVB 2013 Everything About SharePoint 2010 Workflows
SPSVB 2013 Everything About SharePoint 2010 WorkflowsSPSVB 2013 Everything About SharePoint 2010 Workflows
SPSVB 2013 Everything About SharePoint 2010 Workflows
 
Era of server less computing
Era of server less computingEra of server less computing
Era of server less computing
 
Play with azure functions
Play with azure functionsPlay with azure functions
Play with azure functions
 
Writing futuristic workflows in office 365 SharePoint 2013 2016 on premise
Writing futuristic workflows in office 365 SharePoint 2013 2016 on premiseWriting futuristic workflows in office 365 SharePoint 2013 2016 on premise
Writing futuristic workflows in office 365 SharePoint 2013 2016 on premise
 
How we built a job board in one week with JHipster
How we built a job board in one week with JHipsterHow we built a job board in one week with JHipster
How we built a job board in one week with JHipster
 
How we built a job board in one week with JHipster - @KileNiklawski @IpponUSA
How we built a job board in one week with JHipster - @KileNiklawski @IpponUSAHow we built a job board in one week with JHipster - @KileNiklawski @IpponUSA
How we built a job board in one week with JHipster - @KileNiklawski @IpponUSA
 
Timesheet Approval Process
Timesheet Approval ProcessTimesheet Approval Process
Timesheet Approval Process
 
Getting started with content deployment in share point 2013 SPBizConf 2015
Getting started with content deployment in share point 2013 SPBizConf 2015Getting started with content deployment in share point 2013 SPBizConf 2015
Getting started with content deployment in share point 2013 SPBizConf 2015
 
SharePoint Fest Seattle 2017 Getting started with office365 sharepoint online...
SharePoint Fest Seattle 2017 Getting started with office365 sharepoint online...SharePoint Fest Seattle 2017 Getting started with office365 sharepoint online...
SharePoint Fest Seattle 2017 Getting started with office365 sharepoint online...
 
Getting started with Content Deployment in SharePoint 2013
Getting started with Content Deployment in SharePoint 2013Getting started with Content Deployment in SharePoint 2013
Getting started with Content Deployment in SharePoint 2013
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
SharePoint logging & debugging
SharePoint logging  & debugging SharePoint logging  & debugging
SharePoint logging & debugging
 
Profiling and Tuning a Web Application - The Dirty Details
Profiling and Tuning a Web Application - The Dirty DetailsProfiling and Tuning a Web Application - The Dirty Details
Profiling and Tuning a Web Application - The Dirty Details
 
Benchmarking at Parse
Benchmarking at ParseBenchmarking at Parse
Benchmarking at Parse
 

Mehr von Prashant G Bhoyar (Microsoft MVP)

Mehr von Prashant G Bhoyar (Microsoft MVP) (20)

Building Intelligent bots using microsoft bot framework and cognitive service...
Building Intelligent bots using microsoft bot framework and cognitive service...Building Intelligent bots using microsoft bot framework and cognitive service...
Building Intelligent bots using microsoft bot framework and cognitive service...
 
Microsoft Flow for SharePoint Designer Workflow Professionals-SPFestDC2019
Microsoft Flow for SharePoint Designer Workflow Professionals-SPFestDC2019Microsoft Flow for SharePoint Designer Workflow Professionals-SPFestDC2019
Microsoft Flow for SharePoint Designer Workflow Professionals-SPFestDC2019
 
Getting Started with SharePoint Patterns and Practices Provisioning Engine-SP...
Getting Started with SharePoint Patterns and Practices Provisioning Engine-SP...Getting Started with SharePoint Patterns and Practices Provisioning Engine-SP...
Getting Started with SharePoint Patterns and Practices Provisioning Engine-SP...
 
Microsoft Bot Framework for SharePoint Developers-SPFestDC2019
Microsoft Bot Framework for SharePoint Developers-SPFestDC2019Microsoft Bot Framework for SharePoint Developers-SPFestDC2019
Microsoft Bot Framework for SharePoint Developers-SPFestDC2019
 
Azure Active Directory (Azure AD) for office 365 Developers : SPFestDC 2019
Azure Active Directory (Azure AD) for office 365 Developers : SPFestDC 2019Azure Active Directory (Azure AD) for office 365 Developers : SPFestDC 2019
Azure Active Directory (Azure AD) for office 365 Developers : SPFestDC 2019
 
Microsoft Flow For Developers
Microsoft Flow For DevelopersMicrosoft Flow For Developers
Microsoft Flow For Developers
 
Introduction to AI and Cognitive Services For Microsoft 365 Developers and In...
Introduction to AI and Cognitive Services For Microsoft 365 Developers and In...Introduction to AI and Cognitive Services For Microsoft 365 Developers and In...
Introduction to AI and Cognitive Services For Microsoft 365 Developers and In...
 
Introduction to AI and Cognitive Services for O365 Devs Azure Bootcamp Reston
Introduction to AI and Cognitive Services for O365 Devs Azure Bootcamp RestonIntroduction to AI and Cognitive Services for O365 Devs Azure Bootcamp Reston
Introduction to AI and Cognitive Services for O365 Devs Azure Bootcamp Reston
 
Azure Active Directory for Office 365 Developers SPFEST DC 2018
Azure Active Directory for Office 365 Developers SPFEST DC 2018Azure Active Directory for Office 365 Developers SPFEST DC 2018
Azure Active Directory for Office 365 Developers SPFEST DC 2018
 
Getting started with Microsoft Graph APIs SP FEST DC 2018
Getting started with Microsoft Graph APIs SP FEST DC 2018Getting started with Microsoft Graph APIs SP FEST DC 2018
Getting started with Microsoft Graph APIs SP FEST DC 2018
 
Introduction to AI and Cognitive Services for Office 365 Developers SPFest DC...
Introduction to AI and Cognitive Services for Office 365 Developers SPFest DC...Introduction to AI and Cognitive Services for Office 365 Developers SPFest DC...
Introduction to AI and Cognitive Services for Office 365 Developers SPFest DC...
 
Building Business Applications for Office 365 SharePoint Online using Azure M...
Building Business Applications for Office 365 SharePoint Online using Azure M...Building Business Applications for Office 365 SharePoint Online using Azure M...
Building Business Applications for Office 365 SharePoint Online using Azure M...
 
Getting started with Office 365 SharePoint Online Workflows : SharePoint Fest...
Getting started with Office 365 SharePoint Online Workflows : SharePoint Fest...Getting started with Office 365 SharePoint Online Workflows : SharePoint Fest...
Getting started with Office 365 SharePoint Online Workflows : SharePoint Fest...
 
Getting Started with SharePoint REST APIs in Custom Sharepoint Workflows - SP...
Getting Started with SharePoint REST APIs in Custom Sharepoint Workflows - SP...Getting Started with SharePoint REST APIs in Custom Sharepoint Workflows - SP...
Getting Started with SharePoint REST APIs in Custom Sharepoint Workflows - SP...
 
Getting Started with Office 365 Developers Patterns and Practices Provisionin...
Getting Started with Office 365 Developers Patterns and Practices Provisionin...Getting Started with Office 365 Developers Patterns and Practices Provisionin...
Getting Started with Office 365 Developers Patterns and Practices Provisionin...
 
Getting Started with Microsoft Graph API SPTechCon Washington DC 2017
Getting Started with Microsoft Graph API SPTechCon Washington DC 2017Getting Started with Microsoft Graph API SPTechCon Washington DC 2017
Getting Started with Microsoft Graph API SPTechCon Washington DC 2017
 
Writing Futuristic Workflows in Office 365 SharePoint On Prem 2013 2016 - SPT...
Writing Futuristic Workflows in Office 365 SharePoint On Prem 2013 2016 - SPT...Writing Futuristic Workflows in Office 365 SharePoint On Prem 2013 2016 - SPT...
Writing Futuristic Workflows in Office 365 SharePoint On Prem 2013 2016 - SPT...
 
Getting started with SharePoint REST API in custom SharePoint workflows Resto...
Getting started with SharePoint REST API in custom SharePoint workflows Resto...Getting started with SharePoint REST API in custom SharePoint workflows Resto...
Getting started with SharePoint REST API in custom SharePoint workflows Resto...
 
SPEngage Raleigh 2017 Azure Active Directory For Office 365 Developers
SPEngage Raleigh 2017 Azure Active Directory For Office 365 DevelopersSPEngage Raleigh 2017 Azure Active Directory For Office 365 Developers
SPEngage Raleigh 2017 Azure Active Directory For Office 365 Developers
 
Getting Started With SharePoint REST API in Nintex Workflows for Office 365 I...
Getting Started With SharePoint REST API in Nintex Workflows for Office 365 I...Getting Started With SharePoint REST API in Nintex Workflows for Office 365 I...
Getting Started With SharePoint REST API in Nintex Workflows for Office 365 I...
 

Kürzlich hochgeladen

Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
lizamodels9
 
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
lizamodels9
 
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
dollysharma2066
 
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai KuwaitThe Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
daisycvs
 
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
daisycvs
 
Nelamangala Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Nelamangala Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Nelamangala Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Nelamangala Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
amitlee9823
 
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
dlhescort
 
Call Girls In Noida 959961⊹3876 Independent Escort Service Noida
Call Girls In Noida 959961⊹3876 Independent Escort Service NoidaCall Girls In Noida 959961⊹3876 Independent Escort Service Noida
Call Girls In Noida 959961⊹3876 Independent Escort Service Noida
dlhescort
 
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabiunwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
Abortion pills in Kuwait Cytotec pills in Kuwait
 

Kürzlich hochgeladen (20)

Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
 
Katrina Personal Brand Project and portfolio 1
Katrina Personal Brand Project and portfolio 1Katrina Personal Brand Project and portfolio 1
Katrina Personal Brand Project and portfolio 1
 
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesMysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
 
(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7
(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7
(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7
 
Cheap Rate Call Girls In Noida Sector 62 Metro 959961乂3876
Cheap Rate Call Girls In Noida Sector 62 Metro 959961乂3876Cheap Rate Call Girls In Noida Sector 62 Metro 959961乂3876
Cheap Rate Call Girls In Noida Sector 62 Metro 959961乂3876
 
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
 
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
 
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai KuwaitThe Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
 
RSA Conference Exhibitor List 2024 - Exhibitors Data
RSA Conference Exhibitor List 2024 - Exhibitors DataRSA Conference Exhibitor List 2024 - Exhibitors Data
RSA Conference Exhibitor List 2024 - Exhibitors Data
 
Falcon Invoice Discounting platform in india
Falcon Invoice Discounting platform in indiaFalcon Invoice Discounting platform in india
Falcon Invoice Discounting platform in india
 
It will be International Nurses' Day on 12 May
It will be International Nurses' Day on 12 MayIt will be International Nurses' Day on 12 May
It will be International Nurses' Day on 12 May
 
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
 
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdfDr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
 
Nelamangala Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Nelamangala Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Nelamangala Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Nelamangala Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
 
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
 
Value Proposition canvas- Customer needs and pains
Value Proposition canvas- Customer needs and painsValue Proposition canvas- Customer needs and pains
Value Proposition canvas- Customer needs and pains
 
Falcon Invoice Discounting: Empowering Your Business Growth
Falcon Invoice Discounting: Empowering Your Business GrowthFalcon Invoice Discounting: Empowering Your Business Growth
Falcon Invoice Discounting: Empowering Your Business Growth
 
Call Girls In Noida 959961⊹3876 Independent Escort Service Noida
Call Girls In Noida 959961⊹3876 Independent Escort Service NoidaCall Girls In Noida 959961⊹3876 Independent Escort Service Noida
Call Girls In Noida 959961⊹3876 Independent Escort Service Noida
 
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabiunwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
 

SPSNJ 2013 Building Solutions using SharePoint TimerJobs

  • 1. #SPSNJ @PGBhoyar Presented By: Prashant G Bhoyar Building Solutions using SharePoint Timer Jobs 05 October 2013
  • 2. #SPSNJ @PGBhoyar Who am I? • SharePoint Consultant at Portal Solutions • Product - AuthentiMate • Services – We love SharePoint .. • Guy with multiple hats • University of Maryland College Park Alumni • Recipient of Antarctic Service Medal
  • 3. #SPSNJ @PGBhoyar What Will We Cover Today? • What are Timer Jobs? • Common business scenarios for Timer Jobs • Timer Job architecture • Developing Timer Jobs • Various approaches to registering Timer Jobs • How to Test/Debug Timer Jobs • Common issues and fixes for Timer Jobs • Timer Jobs best practices • When not to use them
  • 5. #SPSNJ @PGBhoyar What are Timer Jobs? • Perform much of backend work to maintain farm • Run on one or more server at scheduled time • Run periodically and independent of the users • Offload long running processes from web front end server • Run code under higher privileges
  • 6. #SPSNJ @PGBhoyar What are Timer Jobs? • To Summarize,
  • 7. #SPSNJ @PGBhoyar Examples of Timer Jobs in SharePoint • Clean up Old Sites • User Profile Sync • Solution Deployment • Search Index • Various other Automations/Long Running operations
  • 9. #SPSNJ @PGBhoyar LessComplexity Timer Jobs Vs Scheduled Tasks Scheduled Tasks Timer Jobs -Create Console App -Schedule it using Windows Tasks Scheduler -Easy to setup -Create Custom Timer Job -Register in SharePoint -No reporting available -Need to implement custom logging -Can track status, history, change the schedule, start/stop using Central Admin. -Need direct access to SharePoint Servers (Not easy to get) -Request special account to run the Scheduled Tasks -Timer Job runs under SharePoint Timer Job Account -Load Balancing is not available -Load balancing is available -Console Application -Full Access to SharePoint API (SPSite, SPWebApplication)
  • 10. #SPSNJ @PGBhoyar Timer Jobs in SharePoint Farm • Central Admin -> Monitoring ->Review Job Definitions
  • 11. #SPSNJ @PGBhoyar Timer Jobs in SharePoint Farm • Windows SharePoint Services Timer Service(SPTimerV4) run Timer Job • Service must be enabled and running in each server • Start –Administrative Tools -> Services • The timer job executes under OWSTIMER.exe
  • 13. #SPSNJ @PGBhoyar Create Custom Timer Jobs • Visual Studio -> Empty SharePoint Project • Deploy as Farm Solution
  • 14. #SPSNJ @PGBhoyar LessComplexity Architecture of Timer Jobs • Microsoft.SharePoint.Administration.SPJobDefinition : Timer Jobs are created and executed by using this class • Three Constructors • Default (No Parameters): • For internal use • Others : • Job Name • Job Lock Type • Web Application or Service
  • 15. #SPSNJ @PGBhoyar LessComplexity Architecture of Timer Jobs • Parameters of SPJobDefinition Constructor Name Description Name Name of the Job Service An instance of the SPService class that owns this job WebApplication Parent WebApplication Server An instance of the SPServer class associated with this job lockType An SPJobLockType value that indicates the circumstances under which multiple instances of the job can be run simultaneously. http://msdn.microsoft.com/en-us/library/hh528519(v=office.14).aspx
  • 16. #SPSNJ @PGBhoyar LessComplexity Architecture of Timer Jobs • SPJobLockType values Value Description None No locks. The timer job runs on every machine on which the parent service is provisioned. ContentDatabase Job runs for each content database associated with the job's web application. Job Only one server can run the job at a time.
  • 17. #SPSNJ @PGBhoyar LessComplexity Architecture of Timer Jobs • Override the Execute method of the SPJobDefinition class and replace the code in that method with the code that your job requires. • The targetInstanceId maps to the Guid of the Current content database while the timer job is running
  • 21. #SPSNJ @PGBhoyar LessComplexity Two options: • Declarative by using SharePoint Feature • Pros: Easy to deploy and maintain • Cons: Difficult to develop • Programmatically using Server side object model • Pros : Flexible, Easier to Develop • Cons : Difficult to deploy and maintain Deployment and Registration of Custom Timer Jobs
  • 22. #SPSNJ @PGBhoyar LessComplexity Option 01 : Declarative by using SharePoint Feature • Add Feature • Add code to register Timer Job in the FeatureActivated • Add code to delete Timer Job in the FeatureDeActivating Deployment and Registration of Custom Timer Jobs
  • 23. #SPSNJ @PGBhoyar LessComplexity Option 02 : Programmatically using Server side object model • Create Console Application/Power Shell Script • Add code to register Timer Job • Add code to delete Timer Job Deployment and Registration of Custom Timer Jobs
  • 25. #SPSNJ @PGBhoyar LessComplexity • Attach the debugger to “OWSTIMER.EXE” • Debug -> Attach to Process Debug Custom Timer Jobs
  • 26. #SPSNJ @PGBhoyar LessComplexity • Check the History To see when the timer job ran last time Debug Custom Timer Jobs
  • 28. #SPSNJ @PGBhoyar LessComplexity • Change the Schedule using Central Admin • Change the Schedule using PowerShell Commands • $timerJob = Get-SPTimerJob -Identity "SPSDC2013 TimerJob01" • Start-SPTimerJob $timerJob • Easiest : Write Console Application to debug business logic Expedite Debugging
  • 30. #SPSNJ @PGBhoyar LessComplexity Developing Custom Timer Jobs • Set up the solution • Add a class and Inherit from SPJobDefinition • Override Execute Method • Register Timer Jobs
  • 32. #SPSNJ @PGBhoyar Common Issues and Fixes • Redeployment : IISRESET and ReStart Timer Services • Debugging takes lot of time : • Use Console Application to debug the business login during development • Always implement Exception Handling • SPContext is NOT AVAILABLE. Never use it in Timer Jobs. • If you use SiteCollection Feature to register timer job, activate/deactivate using PowerShell • If SPJobLockType is set to ContentDatabase, timer job will get fired multiple times depending on number of Content Databases
  • 33. #SPSNJ @PGBhoyar Best Practices • Always implement Exception Handling • SPContext is NOT AVAILABLE. Never use it in Timer Jobs. • In production restart the Timer Services using command • “Get-SPTimerJob job-timer-recycle | Start-SPTimerJob” • Use Console Application to debug the business login during development
  • 34. #SPSNJ @PGBhoyar When not to use Timer Jobs? • OOTB Options are available • Content/Data needs to be updated synchronously • Simple data processing that can be easily handled with Event Receivers
  • 37. #SPSNJ @PGBhoyar Princeton SharePoint user group • Different SharePoint discussions each month on various topics. Announced on meetup.com • Meets 4th Wednesday of every month • 6pm – 8pm • Infragistics Office • 2 Commerce Drive, Cranbury, NJ • http://www.meetup.com/prin cetonSUG • http://www.princetonsug.com
  • 38. #SPSNJ @PGBhoyar Thank You Event Sponsors • Platinum & Gold sponsors have tables here in the Fireside Lounge • Please visit them and inquire about their products & services • To be eligible for prizes make sure your bingo card is signed by all Platinum/Gold
  • 39. #SPSNJ @PGBhoyar Questions? Feedback? Contact me:  Twitter: @PGBhoyar  Blog: http://pgbhoyar.wordpress.com (limited contents)  Email: pgbhoyar@gmail.com Thank You Organizers, Sponsors and You for Making this Possible.