0

I scheduled quartz jobs using the spring application context to run each night. Now I want to change the cron job for an already running application so it runs an hour later. We want to change the cron job in the application context and then restart the application for changes to take effect. We do not have acces to the database for security reasons.

I use a CronTriggerBean to run a jobDetail and also supply a cron expression. Now if I change the cron expression and restart the application it does not update the actual cron expression, because this is stored in the database.

How can I make sure the cron expression is updated each time I restart the application?

Edit: Quartz takes the cron expression from the application context and stores this internally in the database. Upon restarting the application with the new cron expression it does not update the value in the database and keeps using the old expression.

Stijnvdk
  • 556
  • 4
  • 7
  • 20

2 Answers2

0

Can you publish one JMX Service of Quartz Scheduler that allows to change this at run time more easy:

http://quartz-scheduler.org/api/2.2.0/org/quartz/core/jmx/QuartzSchedulerMBean.html

You can enable this functionality with this property (in your quartz.properties):

org.quartz.scheduler.jmx.export = true

And then you can open your jmxconsole for see the quartz jmx service.

Hope it helps.

Gerard Ribas
  • 717
  • 1
  • 9
  • 17
0

what i understand from your question, you might have below configuration in app context

<property name="cronExpression" value="${cron expression}" />

i.e you externalized your cron expression , in your case database. so you need to change in database to get effective, where else you have the cron expression configured?

pappu_kutty
  • 2,378
  • 8
  • 49
  • 93
  • We load the cron expression from the JNDI of which we make a bean which we reference in the CronTriggerBean defenition. (edit pressed enter to early) – Stijnvdk Oct 25 '13 at 09:38
  • then i dont understand your question, you get cron expression from jndi, then what do you mean "it does not update the actual cron expression, because this is stored in the database". if you change the jdni value for cron and restart the server, on restart the application context will get refreshed. – pappu_kutty Oct 25 '13 at 09:49
  • that is precisely what I mean. Quartz reads the cron expression from the application context and stores this in the database. Upon restart it does not update the value in the database with the new value from the application context. Will edit my original post to reflect this better – Stijnvdk Oct 25 '13 at 13:14