Question

In sitecore we have the possibility of agents and tasks. But it is not very clear when to use which. My situation: I want to run an (possible taking half an hour) importer each night at a specified time. The importer will import data from an external source into sitecore. What is better: an agent or a task?

Was it helpful?

Solution

They roughly mean the same thing.

In the web.config you can define scheduled agents under the <scheduling> section, however some out of the box agents are in the Sitecore.Tasks namespace. So they appear to be one in the same, but really everything is an agent.

In Sitecore itself, under /sitecore/system/tasks you will see definition items for the same thing. These are called "tasks" but in reality, they are just logical definition items that run based on the schedule. In fact, these are just a CMS-friendly way to define what's also in the web.config as agents. There exists a configured agent that processes these from the CMS:

<!-- Agent to process schedules embedded as items in a database -->
<agent type="Sitecore.Tasks.DatabaseAgent" method="Run" interval="00:10:00">
  <param desc="database">master</param>
  <param desc="schedule root">/sitecore/system/tasks/schedules</param>
  <LogActivity>true</LogActivity>
</agent>
<!-- Agent to process tasks from the task database (TaskDatabase) -->
<agent type="Sitecore.Tasks.TaskDatabaseAgent" method="Run" interval="00:10:00" />

So if you want something to be changed in the CMS, create a tasks under the system section. If you want something to be for developers only, create a config patch and apply your own custom <agent> on whatever timer you want.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top