1

I had an old application that was running on websphere and using old cron job scheduling library which was written in house long time ago.

I am trying to convert it to JBOSS EAP6.4 and I could not determine a good way to convert the job scheduler.

Basically, in the old app we were using a config file that lists the jobs and frequency.

This is an example of the config file

year mo dom dow hr mn   prio    persist package.class                       parms
#   ==== == === === == ==   ======= ======= ==============================================  ============================
*    *  *   *   *   15,45    norm     false  com.shaw.CronClass1    O
*    *  *   1,2,3,4,5,6   0-17,19-23   00,30    norm     false  com.CronClass2    B
*    *  *   0   1-23   00,30    norm     false  com.CronClass3    B

The format messy, but basically the first line says: run this job every twice every hour at 15 min and 45 min The second line says: run this job mon-sat between 12AM-5PM and then 7PM-11PM , every 30 minutes.

I want to do something similar with JBOSS , I saw the jboss Timer service http://docs.oracle.com/javaee/6/tutorial/doc/bnboy.html

But I don't think it has all those options and I cannot use those settings in annotation because they can change. that's why we put them in an external file that is loaded when the app starts.

Is there any library, tool or a way to this easily ?

daoud175
  • 106
  • 1
  • 18
  • 1
    Possible duplicate of [Can the EJB 3.1 @Schedule be configured outside of the application code?](http://stackoverflow.com/questions/3950636/can-the-ejb-3-1-schedule-be-configured-outside-of-the-application-code) – CoolBeans Jan 16 '17 at 20:07
  • Hi - you should use the EJB 3.1 timer. The scheduler info can be externalized via the ejb-jar.xml (typically located under your META-INF folder of your EJB JAR file). Please see this duplicate [question](http://stackoverflow.com/questions/3950636/can-the-ejb-3-1-schedule-be-configured-outside-of-the-application-code) for further reference. – CoolBeans Jan 16 '17 at 20:09
  • Also using an EJB 3.1 timer will make your code more portable for future application container migrations. – CoolBeans Jan 17 '17 at 01:44

1 Answers1

0

You can use the Quartz job scheduler API. It allows scheduling both simple timers and CRON timers. The example to set it up with JBoss/ Wildfly is provided here http://www.mastertheboss.com/jboss-frameworks/jboss-quartz/quartz-2-tutorial-on-jboss-as-7

lazyPanda
  • 135
  • 6