5

The process I am developing uses Jobs to run asynchronously. Some steps in the middle of the process change some folders, which makes Sitecore restart. Once Sitecore has restarted the process searches for the job by its Handle. However, it is not found in the JobManager anymore.

I've tried to start the job with the option "AfterLife" set to different values (1 hour, 90 days), to make sure that the job is kept after it finishes. The result didn't change. The job is lost after sitecore restarts.

Further tests indicate that Jobs (not only mine) are not persisted after a Sitecore restart. I've checked it using the *.aspx page described on the following page:

https://briancaos.wordpress.com/2014/11/11/sitecore-job-viewer-see-what-sitecore-is-doing-behind-your-back/

I'm wondering whether there is something that needs to be enabled for the Jobs to be persisted.

Any information that helps me to troubleshoot this process will be appreciated.

  • Some steps in the middle of the process change some folders, which makes Sitecore restart. yes, it does. for this particular reason, you may want to operate your "movable" data in the /data folder which is located out of the /Website, essentially, because of the mentioned issue. for example, the old search indexes (and Lucene) used to work this way – Andrey Bobrov Jun 24 '18 at 21:33
  • As Mark answered- it’s not possible, easily, however what you are describing is exactly how Sitecore Package Deployer was designed. Basically you store the progress of the job in the database, then on initialization (Sitecore restart) you check if there was a previously running job and then continue it. It would require quite a bit of plumbing to get it to work but it IS possible. – jrap Jun 28 '18 at 1:47
  • @jrap, that is exactly what I'm doing. An module installer for PowerShell – Ben Jun 29 '18 at 6:43
6

They don't persist, nor can they (out of the box)

As you've already mentioned, they do not persist across application pool resets. You're not doing anything wrong, they just aren't designed to persist. They live in the memory of whatever server triggered them.

So as far as "traditional Sitecore" goes, be it Scheduled Tasks, Jobs or Agents - you are out of luck. There's nothing you can do (out of the box) to have these persist across AppPool resets.

AfterLife is just an option to keep your task alive after it finished (in memory, still) so you can check on it's status (e.g. Status: Completed).

A job runs as a thread, and when the thread returns, the job is finished. Sitecore keeps the job around for a limited amount of time afterwards in case you want to check its status. This is called the “after-life”.

By default the after-life value is 1 minute. It can be changed using the Options property on the job.

Source: Sitecore Asynchronous Tasks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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