June 2018
Beginner
722 pages
18h 47m
English
Vert.x also allows us to create a periodic service, which does something at a regular interval. Here is an example:
package com.packt.javapath.ch18demo.microservices;import io.vertx.rxjava.core.AbstractVerticle;import java.time.LocalTime;import java.time.temporal.ChronoUnit;public class PeriodicService1 extends AbstractVerticle { public void start() throws Exception { LocalTime start = LocalTime.now(); vertx.setPeriodic(1000, v-> { System.out.println("Beep!"); if(ChronoUnit.SECONDS.between(start, LocalTime.now()) > 3 ){ vertx.undeploy(deploymentID()); } }); System.out.println("Vertical PeriodicService1 is deployed"); } public void stop() throws Exception { System.out.println("Vertical PeriodicService1 is ...
Read now
Unlock full access