Hi,
We have been working on Threading related changes on engine to move from java
ExecutorServices to JBoss ManagedExecutorServices. The dependency on quartz for
running scheduled jobs is being phased out and we are moving to scheduling jobs using
JBoss ManagedScheduledExecutorService.
As far as development goes it should be pretty straight forward.
Inject the JBoss ManagedScheduledExecutorService
@Inject
@ThreadPools(ThreadPools.ThreadPoolType.EngineScheduledThreadPool)
private ManagedScheduledExecutorService executorService;
and then in PostConstruct you can schedule the job on the executor service using a cron
expression.
@PostConstruct
private void init() {
executor.schedule(this::cleanup, new EngineCronTrigger(cronExpression));
}
To schedule a job to execute at regular intervals you can use the scheduleWithFixedDelay
@PostConstruct
private void init() {
scheduledExecutorService.scheduleWithFixedDelay(this::cleanExpiredUsersSessions,
1,
1,
TimeUnit.MINUTES);
}
If you have any questions please feel free to contact me or Martin Perina (mperina@redhat.com).
Thanks
Ravi