Vert.x-CronUtils is an implementation of the cron-utils library for Vert.x.
This module allows scheduling tasks with unix cron expressions.
To use the Vert.x Cron-Utils, add the following dependency to the dependencies section of your build descriptor:
-
Maven (in your
pom.xml
):
<dependency>
<groupId>com.noenv</groupId>
<artifactId>vertx-cronutils</artifactId>
<version>4.5.9</version>
</dependency>
-
Gradle (in your
build.gradle
file):
compile 'com.noenv:vertx-cronutils:4.5.9'
You can create cron schedulers using the following flavours Unix
, Cron4j
and Quartz
CronScheduler
.create(vertx, "0/1 * * * * ?", CronType.QUARTZ) //trigger every second
.schedule(s ->
System.out.println("timer triggered")
);
CronScheduler
.create(vertx, "0 * * * * ?") //trigger every minute
.schedule(s -> {
s.cancel();
System.out.println("timer triggered and canceled");
});