NoEnv / vertx-cronutils

An abstraction of cron-utils for the vertx scheduler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

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

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

About

An abstraction of cron-utils for the vertx scheduler

License:Apache License 2.0


Languages

Language:Java 100.0%