Skip to content

Commit

Permalink
[New Doc PR] - Helidon SE Scheduling documentation helidon-io#4312 (h…
Browse files Browse the repository at this point in the history
…elidon-io#4525)

* SE Scheduling New Style Documentation initial commit

* Fix copyright year

* Fix comments

Co-authored-by: Romain Grecourt <romain.grecourt@oracle.com>
  • Loading branch information
dalexandrov and romain-grecourt committed Jul 21, 2022
1 parent 891dbaf commit 288bf70
Showing 1 changed file with 68 additions and 13 deletions.
81 changes: 68 additions & 13 deletions docs/se/scheduling.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,25 @@
:toc-placement: preamble
:description: Scheduling in Helidon SE
:keywords: helidon, se, scheduling
:h1Prefix: SE
:feature-name: Scheduling
:rootdir: {docdir}/..
include::{rootdir}/includes/se.adoc[]
== Contents
- <<Overview, Overview>>
- <<Maven Coordinates, Maven Coordinates>>
- <<Usage, Usage>>
- <<Configuration, Configuration>>
- <<Examples, Examples>>
- <<Reference, Reference>>
== Overview
Scheduling is an essential feature for the Enterprise. Helidon has its own implementation of Scheduling functionality
based on https://github.com/jmrozanec/cron-utils[Cron-utils].
include::{rootdir}/includes/dependencies.adoc[]
[source,xml]
Expand All @@ -35,14 +50,13 @@ include::{rootdir}/includes/dependencies.adoc[]
</dependency>
----
== Scheduling
For scheduling periodic tasks it is possible to choose fixed rate setup or Cron expression.
== Usage
For scheduling periodic tasks, it is possible to choose a fixed rate or a Cron expression.
=== Fixed rate
For simple fixed rate invocation use .
[source,java]
.Example of scheduling with fixed rate use `Scheduling.fixedRateBuilder()` builder.
.Scheduling with fixed rate use `Scheduling.fixedRateBuilder()` builder.
----
Scheduling.fixedRateBuilder()
.delay(10)
Expand All @@ -56,7 +70,7 @@ Metadata like human-readable interval description or configured values are avail
FixedRateInvocation provided as task parameter.
[source,java]
.Example with invocation metadata
.Invocation metadata
----
Scheduling.fixedRateBuilder()
.delay(10)
Expand All @@ -66,28 +80,69 @@ Scheduling.fixedRateBuilder()
=== Cron expression
For more complicated interval definition, cron expression can be leveraged with
For more complicated interval definition, Cron expression can be leveraged with
`Scheduling.cronBuilder()` builder.
[source,java]
.Example of scheduling with cron expression
.Scheduling with Cron expression
----
Scheduling.cronBuilder()
.expression("0 15 8 ? * *")
.task(inv -> System.out.println("Executer every day at 8:15"))
.build();
----
== Configuration
Configuration properties are added to `application.yaml` file:
.Configuration properties
[width="90%",cols="3,10",frame="topbot",options="header"]
|====
| Property | Description
| cron | String containing Cron setup
| concurrent | Boolean, equivalent `concurrentExecution` property of `@Scheduled`. Default `true`.
|====
=== Cron expression
Cron expressions should be configured as follows.
include::{rootdir}/includes/cron.adoc[lines=19..]
Metadata like human-readable interval description or configured values are available through
CronInvocation provided as task parameter.
== Examples
=== Fixed rate
For simple fixed rate invocation use .
[source,java]
.Example of scheduling with fixed rate use `Scheduling.fixedRateBuilder()` builder.
----
Scheduling.fixedRateBuilder()
.delay(10)
.initialDelay(5)
.timeUnit(TimeUnit.MINUTES)
.task(inv -> System.out.println("Every 10 minutes, first invocation 5 minutes after start"))
.build();
----
Metadata like human-readable interval description or configured values are available through
`FixedRateInvocation` provided as task parameter.
[source,java]
.Example with invocation metadata
----
Scheduling.cronBuilder()
.expression("0 15 8 ? * *")
.task(inv -> System.out.println("Method invoked " + inv.description()))
.build();
----
Scheduling.fixedRateBuilder()
.delay(10)
.task(inv -> System.out.println("Method invoked " + inv.description()))
.build();
----
== Reference
* https://github.com/jmrozanec/cron-utils[Cron-utils GitHub page]
* link:{scheduling-javadoc-base-url}/io/helidon/microprofile/scheduling/package-summary.html[Helidon Scheduling JavaDoc]

0 comments on commit 288bf70

Please sign in to comment.