views:

455

answers:

1

Timer Tasks in Java EE are not very comfortable. Is there any util, to configure timer with cron syntax like "0 20 20 * * "?

I wonder, if it would be a good way to use Quartzinside (clustered) JEE application. According to http://www.prozesse-und-systeme.de/serverClustering.html (german page) there limits with Quartz and Java EE clustering:

  • JDBC must be used as job store for Quartz
  • Only cluster associated Quartz instances are allowed to use this JDBC job store
  • All cluster nodes must be synchronized to the split second
  • All cluster nodes must use the same quartz.properties file

I would prefer an easier way for configuration of timer service, instead an not Java EE managed scheduler.

+2  A: 

Quartz definitely support cron-like syntax (with the CronTrigger) but your requirements are not clear. Also maybe have a look at Jcrontab or cron4j.


As a side note, the ability to declaratively create cron-like schedules to trigger EJB methods is one of the most important enhancement of the Timer Service in EJB 3.1 (using the @Schedule annotation). Below, an example taken from New Features in EJB 3.1:

@Stateless
public class NewsLetterGeneratorBean implements NewsLetterGenerator {

    @Schedule(second="0", minute="0", hour="0",
                  dayOfMonth="1", month="*", year="*")
    public void generateMonthlyNewsLetter() {
        ... Code to generate the monthly news letter goes here...
    }
}
Pascal Thivent
Thanks a lot. I want to use JEE only stuff. TimerService.createCalendarTimer(ScheduleExpression) is my favorite. Details are available at http://jcp.org/en/jsr/detail?id=318
marabol
@marabol If JEE6 is an option, it's a wise choice indeed.
Pascal Thivent