0

I came across a very interesting scenario I need a Timer for Item added Event receiver for a SharePoint List and this list is being added to hundred of Webs. Now each List needs a timer job, which will run for 2 hours and then perform some actions (after 2 hours of after a item is added it will perform some actions..)

I thought about using SharePoint timer job but then using 100's of sharepoint timer jobs would decrease the performance. Does anyone knows what would be the best solution. I can also use K2 2003 to solve the problem.

[Edit] I am about to create a Database table which will store information about Item, as I don't want a timer job to Trawl thousands of sites, will be a performance issue, then a custom timer job will preodically keep checking database, if there is any item exists with date/time passed over 2 hours and perform actions I want it to :).

1
  • Creating your own database is going to be more work than creating an SPWorkItemJobDefinition and if you want to make it secure probably also slower. Commented Jul 25, 2012 at 18:20

1 Answer 1

3

I would suggest a subtype of the timer job, the SPWorkItemTimerJobDefinition. Waldek Mastykarz wrote a good introduction to using them, and apparently they are available in SharePoint 2007.

Basically, in your event handler you can raise a 'work item' for each item, which includes a date/time that you'd like that item processed. Your timer job then periodically trawls through the system looking for work items that need processed.

This way, you would only need 1 timer job.

4
  • +1, trawling gonna be a issue here tho, as got thousands of webs... Commented Jul 25, 2012 at 13:01
  • Actually, it's not too bad. The Work Items are stored at the SPSite level - so you only have to iterate over the site collections, not the SPWebs, and the timer job looks after that for you. I've used this with some moderately large systems, and it was fine.
    – Andy Burns
    Commented Jul 25, 2012 at 14:07
  • hmmm, but for each client we have atleast 3 site collections and there hundreds of clients, and My manager said it wont gonna be efficient so I gonna follow him, but thanks for telling me about this sub timer :) Commented Jul 25, 2012 at 14:16
  • You'll not be able to create anything which is more efficient that an SPWorkItemJobDefinition, the trawling is an UPDATE dbo.ScheduledWorkItems ... WHERE Type = @WorkItemType AND DeliveryDate <= @Now to make sure two instances of the timerjob isn't processing the same items follow by an SELECT for the marked items and this is per content database. There is NO way you can create anything more effective in SharePoint. Commented Jul 25, 2012 at 18:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.