Simplest Possible Quarkus Scheduler / Timer does not support EJBs and so EJB Timers (like e.g.: Simplest Possible EJB 3.1 Timer). The extension quarkus-scheduler (to install use: mvn quarkus:add-extension -Dextensions=quarkus-scheduler) offers adequate functionality:

import java.time.LocalDateTime;
import java.util.concurrent.atomic.AtomicLong;

import javax.enterprise.context.ApplicationScoped;

import io.quarkus.scheduler.Scheduled;

public class Scheduler {

    private AtomicLong COUNTER = new AtomicLong();

    public void increase() {
        System.out.println("+"+COUNTER.incrementAndGet() + " " +;

    public void decrease() {
        System.out.println("-"+COUNTER.decrementAndGet() + " " +;

2019-07-12 06:16:48,316 INFO  [io.qua.dep.QuarkusAugmentor] (main) Beginning quarkus augmentation
2019-07-12 06:16:48,855 INFO  [io.qua.dep.QuarkusAugmentor] (main) Quarkus augmentation completed in 539ms
2019-07-12 06:16:49,053 INFO  [io.quarkus] (main) Quarkus 0.19.0 started in 0.808s. Listening on: http://[::]:8080
2019-07-12 06:16:49,055 INFO  [io.quarkus] (main) Installed features: [cdi, resteasy, scheduler]
+1 2019-07-12T06:16:49.064741
-0 2019-07-12T06:16:49.064740
+1 2019-07-12T06:16:50.055152
-0 2019-07-12T06:16:51.053965
+1 2019-07-12T06:16:51.054133
+2 2019-07-12T06:16:52.058805

See you at Web, MicroProfile and Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home:


Anyway, in cloud environment (Openshift, Kubernetes), I would recommend not to use Quarkus (or JavaEE) native schedulers. You'll get troubles with leader election, if your schedulers must be run only once at the time, etc. Use Kubernetes and Openshift native cronjobs.

Posted by zemiak on July 11, 2019 at 12:33 PM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed
Online Workshops
...the last 150 posts
...the last 10 comments