Skip to Content
author's profile photo Former Member
Former Member

Job Scheduling, which base on Core +, does not work with Data Hub war project. why?

related three files.

  1. applicationContext.xml

  2. HelloWorkerBean

  3. com.hybris.datahub_datahub-webapp-logback.xml

part1. applicationContext.xml

  <bean id="helloWorker" class="com.example.HelloWorkerBean"  name="helloWorker">
  </bean> 
 <bean id="helloJob" class="com.hybris.kernel.api.StatefulJobDetailsBean"  name="helloJob">
     <property name="cronExpression" value="*/1 * * * * ?" />
     <property name="jobParams" value="Hello World!" />
     <property name="worker" ref="helloWorker" />
     <property name="scope" value="ALL_TENANT" />
 </bean>


part2. HelloWorkerBean

package com.example;

import java.io.Serializable;

import org.apache.commons.logging.Log;

import org.apache.commons.logging.LogFactory;

import com.hybris.kernel.api.JobContext;

import com.hybris.kernel.api.StatefulJobWorkerBean;

public class HelloWorkerBean implements StatefulJobWorkerBean {

 private static Log log = LogFactory.getLog(HelloWorkerBean.class);
 private String beanName;
 
 @Override
 public void execute(final Serializable params, final JobContext jobContext)
 {
     System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>> params : " + params);
     log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>> params : " + params);
 }
 
 @Override
 public void setBeanName(final String name)
 {
     beanName = name;
 }
 
 @Override
 public String getBeanName()
 {
     System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>> beanname : " + beanName);
     log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>> beanname : " + beanName);
     return beanName;
 }

}

part3. com.hybris.datahub_datahub-webapp-logback.xml

 <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
     <encoder>
         <Pattern>[%level] [%logger] %msg%n</Pattern>
     </encoder>
 </appender>
 
 <logger name="com.hybris.kernel.api" level="info" />
 <logger name="com.example" level="info" />
 <logger name="com.hybris.datahub.integration.jobs" level="info" />
 <logger name="com.hybris.kernel.services.aggregation" level="info" />
 <logger name="com.hybris.kernel" level="info" />
 <logger name="com.hybris.kernel.typesystem" level="info" />
 <!--logger name="com.hybris.kernel.engine.jdbc" level="trace" /-->
 <logger name="com.hybris.kernel.utils.SystemInformationLogger" level="info" />
 <logger name="com.hybris.datahub" level="debug" />
 <logger name="com.hybris.datahub.service.integration.impl.BlockingPollingConsumer" level="info" />
 <root level="info">
     <appender-ref ref="STDOUT" />
 </root>
 <contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
     <resetJUL>true</resetJUL>
 </contextListener>


@Job Scheduling in Core+ https://wiki.hybris.com/pages/viewpage.action?pageId=139789694#JobSchedulinginCore%2B-NoTenantJob

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Dec 16, 2014 at 11:28 AM

    Hi Aron,

    the code looks correct and seems to work.

    But my assumption is that the scheduler is not enabled at all because otherwise you would see some output.

    Can you verify that you have the following import in your application context? < import resource="classpath:/META-INF/kernel-scheduler-spring.xml"/>

    Additionally you could add a < logger name="com.hybris.kernel.scheduler" level="info" /> and verify that you can see the following output: "quartz job scheduler initialized successfully".

    I hope I could help you and if you have any further questions just let me know.

    Matthias

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.