Announcement: You can find the guides for Commerce 7.5 and later on the new Elastic Path Documentation site. This Developer Center contains the guides for Commerce 6.13.0 through 7.4.1.Visit new site

This version of Elastic Path Commerce is no longer supported or maintained. To upgrade to the latest version, contact your Elastic Path representative.

Adding a new scheduled job

Adding a new scheduled job

To add a scheduled job to either the Commerce Manager server or Search server, do the following:

  1. Open the appropriate quartz.xml file:
    • The Commerce Manager server quartz.xml file is located at cmserver\ep-cmserver\src\main\resources\spring\scheduling\quartz.xml
    • The Search server quartz.xml file is located at search\ep-search\src\main\resources\spring\scheduling\quartz.xml
  2. In quartz.xml, define a job bean as shown below:
    <bean id="newJob"
        class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
      <property name="targetObject">
        <ref bean="newJobService"/>
      </property>
      <property name="targetMethod">
        <value>executeMethod</value>
      </property>
      <property name="concurrent">
        <value>false</value>
      </property>
    </bean>
    
  3. Replace the following values:
    • newJob - the name of the bean.
    • newJobService - the class that contains the logic for the scheduled job.
    • executeMethod - the name of the method to execute in the class.
    • concurrent - set to false to prevent jobs from executing concurrently.
  4. In quartz.xml, define a trigger bean as shown below:
    <bean id="newJobTrigger"
        class="org.springframework.scheduling.quartz.CronTriggerBean">
      <property name="jobDetail">
        <ref bean="newJob"/>
      </property>
      <property name="cronExpression">
        <value>0 0 0/1 * * ?</value>
      </property>
    </bean>
    
  5. Replace the following properties:
    • newJob - the name of the job bean.
    • cronExpression - the cron expression that sets how often the job should be executed. For more information on cron expressions, see the Quartz Cron Configuration
  6. Open the appropriate quartz-setup.xml file:
    • The Commerce Manager server quartz-setup.xml file is located at cmserver\ep-cmserver\src\main\filtered-resources\spring\scheduling\quartz-setup.xml
    • The Search server quartz-setup.xml file is located at search\ep-search\src\main\filtered-resources\spring\scheduling\quartz-setup.xml
  7. Add the new trigger to the list of triggers. For the Commerce Manager server, it will look similar to the code below:
    <util:list id="schedulingTriggers">
    	<ref bean="cleanupOrderLocksTrigger"/>
    	<ref bean="processImportJobTrigger"/>
    	<ref bean="importJobCleanupTrigger"/>
    	<ref bean="staleImportJobTrigger"/>
    	<ref bean="cleanupSessionsTrigger"/>
    	<ref bean="cleanupAbandonedCartsTrigger"/>
    	<ref bean="cleanupFailedOrdersTrigger"/>
    	<ref bean="cleanupFailedOrdersTrigger"/>
    
    	<!-- add the reference to the new trigger here -->
    	<ref bean="newJobTrigger" />
    </util:list>