[ovirt-devel] Quartz -> ManagedScheduledExecutorService

Ravi Shankar Nori rnori at redhat.com
Thu Jul 27 18:42:10 UTC 2017


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 at redhat.com).

Thanks

Ravi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ovirt.org/pipermail/devel/attachments/20170727/160ece27/attachment.html>


More information about the Devel mailing list