You are here: Architecture > Long Running Processes and Scheduling

Long Running Processes and Scheduling

Long running process are tasks that can take long time to execute or have to be performed regulary. These are the tasks like search indexing, processing payment plans and so on. EPiServer Commerce uses quart (quartznet.sourceforge.net/tutorial) to execute scheduled jobs. It is running as a windows service and is specific for each EPiServer Commerce "application". You should have one running after the installation is complete.

These jobs are configured in quartz_jobs.xml file.

To add a new scheduled job do the following:

1. Create a job class that implements IStatefulJob interface.

public class PaymentPlanJob : IStatefulJob
    {
        private readonly ILog _Log = null;
 
        /// <summary>
        /// Initializes a new instance of the <see cref="PaymentPlanJob"/> class.
        /// </summary>
        public PaymentPlanJob()
        {
            _Log = LogManager.GetLogger(GetType());
        }
 
        #region IJob Members
 
        /// <summary>
        /// Executes the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        public void Execute(JobExecutionContext context)
        {
            string applicationName = context.JobDetail.Group;
 
            if (String.IsNullOrEmpty(applicationName) || applicationName == "all") // index all applications
            {
                AppDto dto = AppContext.Current.GetApplicationDto();
 
                foreach (AppDto.ApplicationRow row in dto.Application)
                {
                    DoSomething(row.Name);
                }
            }
            else
            {
                DoSomething(applicationName);
            }
        }
        #endregion
   }

 

2. Define Job details.

<job-detail>
	<name>PaymentPlanJob</name>
	<group>all</group>
	<description>This job processes recurring payments.</description>
	<job-type>Mediachase.Commerce.Services.PaymentPlanJob, Mediachase.Commerce.Services.PaymentPlanJob</job-type>
	<volatile>false</volatile>
	<durable>true</durable>
	<recover>false</recover>
</job-detail>

 

3. Define Job trigger which determines how often the job is executed.

<trigger>
	<simple>
		<name>PaymentPlanJobTrigger</name>
		<group>eCommerceFramework</group>
		<description>Fires Payment Plan Job</description>
		<misfire-instruction>SmartPolicy</misfire-instruction>
		<volatile>false</volatile>
		<job-name>PaymentPlanJob</job-name>
		<job-group>eCommerceFramework</job-group>
		<repeat-count>RepeatIndefinitely</repeat-count>
		<repeat-interval>300000</repeat-interval>
	</simple>
</trigger>

 

4. Restart "Mediachase eCommerce Framework Quartz (ApplicationName)" windows service.

Provided Out of the Box Jobs

 


Version: EPiServer Commerce 1 R2 SP1 | Last updated: 2012-02-13 | Copyright © EPiServer AB | Send feedback to us