Skip to content

NoEnv/vertx-cronutils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Code Coverage Maven Central

Vert.x-CronUtils

Vert.x-CronUtils is an implementation of the cron-utils library for Vert.x.

This module allows scheduling tasks with unix cron expressions.

Using Vert.x-CronUtils

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.11</version>
</dependency>
  • Gradle (in your build.gradle file):

compile 'com.noenv:vertx-cronutils:4.5.11'

Creating a cron scheduler

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");
    });