Spring and 2 Quartz job running

A

Alessandro

Hi all,

I'm adding a new job (CoraxJob) to a Spring application already
working and using a single job (FinecoJob).

Result: my new job doesn't start and I don't get any error.

MyScheduler is the main class which loads context

//START
myconfig.xml

<!-- *** INIZIO SCHEDULER *** -->
<bean class="org.springframework.scheduling.quartz.JobDe tailBean"
id="jobDetailBean">
<property name="jobClass" value="FinecoJob"></property>
<property name="jobDataAsMap">
<map>
<entry key="message" value="Welcome at Fineco Job"></entry>
</map>
</property>
</bean>
<bean class="org.springframework.scheduling.quartz.JobDe tailBean"
id="jobDetailCoraxBean">
<property name="jobClass" value="CoraxJob"></property>
<property name="jobDataAsMap">
<map>
<entry key="message" value="Welcome at Corax Job"></entry>
</map>
</property>
</bean>
<bean id="myCronTrigger"
class="org.springframework.scheduling.quartz.CronT riggerBean">
<property name="jobDetail" ref="jobDetailBean"></property>
<property name="cronExpression" value="00 54 19 ? * TUE-SAT *"></
property>
</bean>
<bean id="myCoraxTrigger"
class="org.springframework.scheduling.quartz.CronT riggerBean">
<property name="jobDetail" ref="jobDetailCoraxBean"></property>
<property name="cronExpression" value="00 45 16 ? * MON-FRI *"></
property>
</bean>
<bean class="org.springframework.scheduling.quartz.Sched
ulerFactoryBean">
<property name="triggers">
<list>
<ref bean="myCronTrigger" />
<ref bean="myCoraxTrigger" />
</list>
</property>
</bean>
<!-- *** FINE SCHEDULER *** -->


MyScheduler.java
public class MyScheduler {

public static ApplicationContext context;
public static void main(String[] args) throws SchedulerException{
try{
context=new FileSystemXmlApplicationContext(myconfig.xml);
}
catch(Throwable ex){
}
}

FinecoJob.java
public class FinecoJob extends QuartzJobBean implements
StatefulJob,Costants {
public static ApplicationContext context;

protected void executeInternal(JobExecutionContext ctx)
throws JobExecutionException {

context=MyScheduler.context;
.....
//MY JOB ...



CoraxJob.java
public class CoraxJob implements Costants{
public static ApplicationContext context;

protected void executeInternal(JobExecutionContext ctx)
throws JobExecutionException {

//MY JOB

//END

Is anything wrong in what I have done ? I thought it was just simply
adding the new job ad CronTriggerBean and JobDetailBean.

They will be two jobs starting in different hours and using a
different method executeInternal().

Thanks for any help and best regards,
Ale
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top