Quartz Spring CronTrigger发射次数超过配置次数 [英] Quartz Spring CronTrigger fired more times than configured

查看:239
本文介绍了Quartz Spring CronTrigger发射次数超过配置次数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个cronTrigger工作digestJob:

I have a cronTrigger for a job "digestJob":

<bean id="digestCronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"> 
    <property name="jobDetail" ref="digestJob" />
    <property name="cronExpression" value="0 35 15 * * ?" />
</bean>

这是我的schedulerFactoryBean配置:

Here is my schedulerFactoryBean configuration:

<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="triggers">
            <list>
                <ref bean="digestCronTrigger" />   
            </list>
        </property>
    </bean>

问题是,digestCronTrigger应该每天下午5:35被解雇,但它在指定时间被​​解雇TWICE。但是,当我使用SimpleTrigger时:

The problem is, the digestCronTrigger is supposed to be fired ONCE everyday at 5:35 PM, but it is being fired TWICE at the specified time. However, when I use SimpleTrigger:

<bean id="digestTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
        <property name="jobDetail" ref="digestJob" />
        <property name="startDelay" value="0" />
        <property name="repeatInterval" value="10000" />
    </bean>

一切正常,触发器每10秒触发一次。为什么digestCronTrigger被解雇了两次?我的cron表达式有问题,还是有任何我失踪的属性?任何帮助将不胜感激。

everything works fine and the trigger is fired exactly once every 10 seconds. Why digestCronTrigger is being fired twice? Is there something wrong with my cron expression, or is there any property that I am missing? Any help will be much appreciated.

推荐答案

我发布了在泉源论坛的同样问题,我帮助找出问题背后的原因:
我正在加载应用程序上下文两次。后来我发现从这篇文章如何避免加载上下文两次。现在情况正常。

I posted same question at springsource forums where I got help to figure out the cause behind the problem: I was loading the application context twice. Later I found from this post how to avoid loading the context twice. Now things are working fine.

这篇关于Quartz Spring CronTrigger发射次数超过配置次数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆