Skip to content

Commit

Permalink
Mention ScheduledExecutorService in scheduler reference doc
Browse files Browse the repository at this point in the history
  • Loading branch information
manovotn committed Apr 4, 2024
1 parent 7095bee commit e4ed465
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/src/main/asciidoc/scheduler-reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,23 @@ NOTE: By default, the scheduler is not started unless a `@Scheduled` business me

NOTE: If the xref:quartz.adoc[Quartz extension] is present and the DB store type is used then it's not possible to pass a task instance to the job definition and a task class must be used instead. The Quartz API can be also used to schedule a job programmatically.

In certain cases, a more fine-grained approach might be needed which is why Quarkus also exposes `java.util.concurrent.ScheduledExecutorService` and `java.util.concurrent.ExecutorService` that can be injected as CDI beans.
However, these executors are used by other Quarkus extensions and therefore should be approached with caution. Furthermore, users are never allowed to shut these executors down manually.

[source,java]
----
class JobScheduler {
@Inject
ScheduledExecutorService executor;
void everySecondWithDelay() {
Runnable myRunnable = createMyRunnable();
executor.scheduleAtFixedRate(myRunnable, 3, 1, TimeUnit.SECONDS);
}
}
----

== Scheduled Methods and Testing

It is often desirable to disable the scheduler when running the tests.
Expand Down

0 comments on commit e4ed465

Please sign in to comment.