question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Investigate possibility to use a lazy threadpool for Quartz backed scheduler

See original GitHub issue

A recently merged PR https://github.com/quarkusio/quarkus/pull/4554 adds code which doesn’t start the Scheduler if there’s no @Scheduled annotations detected. A side-effect of this is that the Schduler if injected and used programmatically to start timers, will no longer function.

The reason why the start() of the scheduler has been skipped, when no @Scheduled is present is to prevent Quartz from eagerly starting a threadpool with certain (configured) number of threads. Details here https://github.com/quarkusio/quarkus/issues/4243. Looking at the implementation of the default and the only functional thread pool that comes in Quartz (org.quartz.simpl.SimpleThreadPool), it creates a fixed set of threads eagerly and doesn’t let users configure the pool to be lazily initialized. This enhancement request is to investigate if it’s possible to use Quarkus internal thread pool as an implementation of org.quartz.spi.ThreadPool

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mkoubacommented, Dec 13, 2019

Just one more comment - the handler passed to the Vertx.setTimer() method is executed using the event loop thread and so the code should not block. If you need to perform some blocking/long-running operation use the Vertx.executeBlocking() method inside the handler:

@Inject Vertx vertx;
// …
vertx.setTimer(delay, id -> {
   vertx.executeBlocking(p -> {
      // ...
    }, p -> {});
});

See https://vertx.io/docs/vertx-core/java/#blocking_code for more information.

1reaction
mkoubacommented, Dec 9, 2019

That means that the Scheduler extension API only supports declarative approach via the @Scheduled annotation.

for cron-like tasks

Not really. You can use @Scheduled(every="10s") where the value is parsed with Duration#parse(). The value is always rounded to full second.

For programmatic approach you could try Vertx.setTimer(long, Handler<Long>) and Vertx.setPeriodic(long, Handler<Long>) methods for non-blocking stuff (see https://vertx.io/docs/vertx-core/java/#_executing_periodic_and_delayed_actions). We will probaly add support for an injectable java.util.concurrent.ScheduledExecutorService for blocking tasks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ThreadPool (Quartz Enterprise Job Scheduler 2.2.3 API)
The interface to be implemented by classes that want to provide a thread pool for the QuartzScheduler 's use. ThreadPool implementation instances should...
Read more >
Splitting log4j Output with Quartz Worker Threads
I'm working on an application that consists of an overall Quartz-based scheduler and "CycledJob" run using ...
Read more >
Scheduling Periodic Tasks with Quartz - Quarkus
Modern applications often need to run specific tasks periodically. In this guide, you learn how to schedule periodic clustered tasks using the Quartz...
Read more >
Scheduling Jobs with Spring and Quartz - LinkedIn
In short it is possible to use a completely Spring-based scheduler, ... an in-memory Quartz scheduler using Spring-backed Quartz objects, ...
Read more >
Chapter 23. Scheduling and Thread Pooling - Spring
By default, Quartz Jobs are stateless, resulting in the possibility of jobs interfering with each other. If you specify two triggers for the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found