Reputation: 301
I'd like to run a job every first and third Monday of the month. I'm using a CronTriggerBean that I'm trying to configure with the following expressions but i doesn't work:
<property name="cronExpression" value="0 0 12 ? * MON#1,3 *" />
or
<property name="cronExpression" value="0 0 12 ? * MON#1,MON#3 *" />
The first expression only runs the job on the first Monday while the second one runs the job on the third Monday.
Is there any way I could achieve this with a CronTriggerBean? I'm using quartz-1.6.5 with XML config so I don't think I could configure a SimpleTriggerBean to do it.
Upvotes: 1
Views: 2465
Reputation: 715
Why don't you configure two Quartz-cron jobs triggering same module ?
First Monday of every month - 0 0 12 ? 1/1 MON#1 *
Second Monday of every month - 0 0 12 ? 1/1 MON#2 *
Upvotes: 1
Reputation: 7867
You won't be able to do that with a single trigger bean. You will need to create 2 separate and register them with the scheduler:
<bean id="cronTriggerJobFirstMonday"
class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="YourQuartzJobBean" />
<property name="cronExpression" value="0 0 12 ? * MON#1 *" />
</bean>
<bean id="cronTriggerJobThirdMonday"
class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="yourQuartzJobBean" />
<property name="cronExpression" value="0 0 12 ? * MON#3 *" />
</bean>
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="cronTriggerJobFirstMonday" />
<ref bean="cronTriggerJobThirdMonday" />
</list>
</property>
</bean>
Upvotes: 1