简体   繁体   English

春天的Cron表达

[英]Cron Expression in Spring

I have one requirement to send mails on weekly basis at some point based on some database check and its working perfectly fine with below config. 我有一个要求,根据数据库检查,在某个时候每周发送邮件,它在以下配置下工作正常。

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

<bean id="emailWeeklyTrigger"   class="org.springframework.scheduling.quartz.CronTriggerBean"> 
    <property name="jobDetail" ref="emailWeeklyNotification" />  
    <property name="cronExpression" value="${email.weekly.sched}" /> 
</bean>

<bean id="emailWeeklyNotification" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">     
    <property name="targetObject" ref="emailService" />
    <property name="targetMethod" value="myMthod" />     
</bean>

${email.weekly.sched} for this value is coming from DB like "0 0 6 ? * MON" $ {email.weekly.sched}的值来自数据库,例如“ 0 0 6?* MON”

emailService is a my Class which is having this method with some other placeholders. emailService是我的Class,与其他占位符一起使用此方法。

So my question is, what to write in this expression which will break Spring's code so my scheduler method should not be called becuse there is nothing in DB and still mails are going. 所以我的问题是,在此表达式中写什么将破坏Spring的代码,因此不应调用我的调度程序方法,因为DB中没有任何内容,并且仍在发送邮件。

Though this going to be a temp fix becuase we have new code, which is checking the size of collection before sending mails, but not in PROD. 尽管这将是临时修复,因为我们有新的代码,该代码在发送邮件之前检查集合的大小,但不在PROD中。

I tried writing like "0 -1 17 ? * THU" or "0 56 17 ? * FUN" but its failing in deployment itself. 我尝试编写类似“ 0 -1 17?* THU”“ 0 56 17?* FUN”的代码,但是它本身无法部署。

Please suggest. 请提出建议。

Thanks 谢谢

org.springframework.util.StringUtils.CronSequenceGenerator接缝无法使模式停止触发。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM