Question

In my site (SP2010) I've created a trigger which adds a work item to the queue, through the SPSite.AddWorkItem method. This seems to do well, since the ScheduledWorkItems table is being filled with the correct data. Time is set in UTC and is the current or past time. ID's are all set OK as well. So the table has all the right data.

However, the custom created Work Item processor, derived from SPWorkItemJobDefinition, with the correct ID, is never being fired. The AppPool user who adds work items is also a farm admin. There are no entries in the event log or sharepoint log files concerning this process, so it's not even being triggered.

Any more prerequisites for successfully deploying and firing a work item job?

Was it helpful?

Solution

You need to create a running job instance for your work item job definition. A work item job is scheduled as any other job. See SPWorkItemJobDefinition Class:

Serves as the base class for deriving definitions of work-item timer jobs. This class works with the timer job (SPTimerService) to process work items (SPWorkItem instances). [...] This class works closely with the SPWorkItem and SPWorkItemCollection classes. You should use the collection class, to which the SPSite object has access, to add work items to the processing queue. When your work-item timer job executes, [...]

I suggest to create a feature event receiver and create the job instance in the feature activated "event":

SPWebApplication webApp = // ..;
SomeWorkItemJob = new SomeWorkItemJob("TheName", webApp);
job.Schedule = new SPMinuteSchedule { Interval = 2}; // every two minutes
job.Update(false);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top