简体   繁体   English

对于给定的cron表达式,Seam Quartz Dispatcher不会在秒和分钟字段上触发

[英]Seam Quartz Dispatcher not firing on seconds and minutes field for a given cron expression

I have a Quartz job that is to fire for a certain time repeatedly. 我有一个Quartz工作,可以重复一段时间。 Unfortunately it does not fire for some unknown reasons. 不幸的是,由于某些未知原因,它不会触发。

Here is my cron expression : 这是我的cron表达式:

0/5 0 0 * * ?

So basically the job should be fired every 5 seconds. 因此,基本上应该每5秒解雇一次该作业。 This is the part which does not work. 这是不起作用的部分。

Now the wierd thing is when I changed the cron expression to 现在更奇怪的是,当我将cron表达式更改为

0 0 0/1 * * ?

which fire the job at every 1 hour. 每1个小时就会解雇一次。 The job is fired and I can see that the method is being invoked on the Java side. 这项工作被解雇了,我可以看到该方法正在Java端被调用。

I have tried also on the minute field eg. 我也曾在分钟字段上尝试过。 0 0/5 0 * * ? for every 5 minutes but it does not fire either. 每5分钟一次,但也不会触发。

I don't know what is the behavior is that the other two expression are not firing. 我不知道其他两个表达式没有触发是什么行为。 Any help would be very much appreciated. 任何帮助将不胜感激。

Here is also my seam.quartz.properties file 这也是我的seam.quartz.properties文件

Configure Main Scheduler Properties

org.quartz.scheduler.instanceName QuartzScheduler
org.quartz.scheduler.instanceId AUTO
org.quartz.scheduler.rmi.export false
org.quartz.scheduler.rmi.proxy false

Configure ThreadPool

org.quartz.threadPool.class org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount 10

Configure JobStore

org.quartz.jobStore.misfireThreshold 60000
org.quartz.jobStore.class org.quartz.simpl.RAMJobStore

I am using Jboss 5.1.0, Seam 2.2 and Quartz 1.8.3. 我正在使用Jboss 5.1.0,Seam 2.2和Quartz 1.8.3。

0/5 0 0 * * ?

The above cron expression will schedule the job to trigger every 5 seconds during minute 0 and hour 0 daily. 上面的cron表达式将安排作业在每天的0 分钟0 小时内每5秒触发一次。 In other words, the first minute every day, the job will execute 12 times. 换句话说,每天的第一分钟,作业将执行12次。

I assume you want it to trigger any hour, that is every 5 seconds regardless of the hour. 我假设您希望它触发任何一个小时,即每5秒钟触发一次,与小时无关。

Replace the two zeros indicating minute and hour with the * wildcard. *通配符替换表示分钟小时的两个零。 Also, you don't need ? 另外,您不需要? which means no specific value . 这意味着没有具体的价值 The below expression will schedule the timer every 5 seconds, regardless of which hour or minute it is: 下面的表达式将每5秒调度一次计时器,而不管它是小时还是分钟

0/5 * * * * *

The reason why 0 0 0/1 * * ? 0 0 0/1 * * ?的原因0 0 0/1 * * ? is "working" is because you undertand the expression correctly, which you didn't with the ones that were "not working". 之所以说“有效”是因为您正确理解了表达式,而对“无效”的表达式则没有。 Basically it means every 1 hour at the start of a new hour (minute 0 and second 0) . 基本上,这意味着每隔1个小时在一个新的小时开始(分钟0和秒0)开始

This documentation is an excellent resource with examples for Quartz 1.X: 该文档是一个很好的资源,其中包含Quartz 1.X的示例:

http://www.quartz-scheduler.org/documentation/quartz-1.x/tutorials/crontrigger http://www.quartz-scheduler.org/documentation/quartz-1.x/tutorials/crontrigger

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

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