Cron syntax with Java EE 5?

Timer tasks in Java EE are not very convenient. Are there any utilities to set up a timer with cron syntax like "0 20 20 * *"?

I wonder if this was a good way to use the Java EE Quartzinside application (clustered). According to http://www.prozesse-und-systeme.de/serverClustering.html (German page) there is a restriction with clusters of Quartz and Java EE clusters:

  • JDBC should be used as a job repository for Quartz
  • Only clustered Quartz instances are allowed to use this JDBC job store.
  • All cluster nodes must be in sync with the shared second
  • All cluster nodes must use the same quartz.properties file

I would prefer an easier way to configure the timer service than a scheduler not managed by Java EE.

+4
source share
1 answer

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


As a side note, the ability to declaratively create Cron-like schedules for running EJB methods is one of the most important timer service enhancements in EJB 3.1 (using @Schedule ). The following is an example of 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... } } 
+5
source

Source: https://habr.com/ru/post/1299941/


All Articles