Schedule Ejb timer without restoring war

I use the ejb timer in my code as follows:

import org.apache.logging.log4j.Logger; import javax.annotation.Resource; import javax.ejb.Schedule; import javax.ejb.Singleton; import javax.ejb.Startup; import javax.inject.Inject; @Singleton @Startup public class Notifier { @Inject Logger LOG; @Resource(mappedName="java:jboss/mail/Default") private Session mailSession; @Schedule(minute = "0", hour = "*", persistent = false) public void notify() { } } 

I would like to be able to reconfigure the scheduler without having to rebuild and upload the resulting war to the server every time I decide that I need to set up a schedule.

How can I do it?

+5
source share
1 answer

You can use the system property and ScheduleExpression . Or you can use the EJB software timer .

Another option is to use the ManagedScheduledExecutorService and use Trigger to control the next run time. Again, you can use a system property or just a configuration file that lives outside the application.

+2
source

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


All Articles