Showing posts with label hybris4.8.. Show all posts
Showing posts with label hybris4.8.. Show all posts

How To create Cron Job in Hybris e-commerce suite | Interview Question on Hybris 4.8 e-commerce suite

Below given step by step to create hybris cron job

1. create a class MyFirstCronJob as below

/**
*
 */
package se.hm.core.cronjob;

import de.hybris.platform.cronjob.enums.CronJobResult;
import de.hybris.platform.cronjob.enums.CronJobStatus;
import de.hybris.platform.cronjob.model.CronJobModel;
import de.hybris.platform.servicelayer.cronjob.AbstractJobPerformable;
import de.hybris.platform.servicelayer.cronjob.PerformResult;


/**
* @author
 *
 */
public class TestCronJob extends AbstractJobPerformable
{

                /*
                * (non-Javadoc)
                *
                 * @see
                * de.hybris.platform.servicelayer.cronjob.AbstractJobPerformable#perform(de.hybris.platform.cronjob.model.CronJobModel
                * )
                */
                private String exportDir;

                /**
                * @return the exportDir
                */
                public String getExportDir()
                {
                                return exportDir;
                }

                /**
                * @param exportDir
                *           the exportDir to set
                */
                public void setExportDir(final String exportDir)
                {
                                this.exportDir = exportDir;
                }



                @Override
                public PerformResult perform(final CronJobModel arg0)
                {
                                System.out.printlnTestCronJob Job Started");


                                System.out.printlnTestCronJob Job Finished");
                                return new PerformResult(CronJobResult.SUCCESS, CronJobStatus.FINISHED);
                }

}


2. After create  KumudJob.java register this cron job in xml as below

<bean id="myFirstCrobJob" class="se.hm.core.cronjob.TestCronJob" scope="tenant"
                                  parent="abstractJobPerformable">
                                  <property name="exportDir" ref="exportDataBaseDirectory"/>
                </bean>

3. Now Run UPDATE Hybris

4. After UPDATE your created Cron job  KumudJob  will show in list of cronjob in Hmc where you can schedule .