开发者

What's are the benefits of using Web.config scheduled tasks over for example a Windows scheduled task

开发者 https://www.devze.com 2023-01-19 09:08 出处:网络
We are thinking of ways to get our scheduled tasks centralized as much as possible by dragging a lot of tasks from website specific web.config files to one Windows schedules task.

We are thinking of ways to get our scheduled tasks centralized as much as possible by dragging a lot of tasks from website specific web.config files to one Windows schedules task. I can imagine that this has some negative consequences, but I want to list them so I can make myself a good explanation of what will work best. We have different types of task that have to be done periodically like for example:

  • Keepalive <- calls a page so that the website won't be recompiling every 20 minutes (iis setting)
  • Imports in different websites we run <- Imports of for example objects that have to be placed in a Sitecore database.

Sitecore has it's own sch开发者_如何学JAVAeduler and that makes imports very easy to run by just using this scheduler. On the other side, Sitecore also has it's own "KeepAlive" setting in the web.config that makes sure the website runs faster.

What will be the pro's and the con's on this issue and what will you advice? Keep the scheduled tasks centralized? Split the normal imports from the Keepalive tasks and put one of them in a centralized environment?


Sitecore native scheduling is executed within Sitecore context, that means that you can easily communicate with Sitecore this way but the app has to be alive for the task to execute. This is pretty much why it is impossible to run a scheduled agent at a specific time, only on scheduled intervals, as there is no guarantee that application is healthy at a given moment.

Windows tasks are executed outside of the context and can be scheduled at a specific time, but this approach lacks that much needed Sitecore context which may complicate the design a bit, but you can always create a Sitecore web service to handle that.

Among the real world examples I've seen where Windows scheduler approach has been implemented is scenario with "publishing at specific time": http://sitecoreblog.alexshyba.com/2007/02/publish-at-specific-time.html Also I've seen large data pushes implemented, like the one you are talking about. You can pretty much have import code run outside of Sitecore context in a console app. Having access to Sitecore.Configuration.Factory, you can instantiate databases, get items and create items. That's all you need. Plus it is more effective that running such code within http context.


There is also a third option.

In Sitecore you can create tasks in sitecore/system/tasks/schedules/

which in turn calls a Command in sitecore/system/tasks/commands/

which you can create with a reference to a method that gets run.

I haven't tried it myself, so can't help much more than that.

But there you can set a specific time.

There is some help here (though this is for Sitecore 5.3).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号