List of usage examples for io.vertx.core Vertx setPeriodic
long setPeriodic(long delay, Handler<Long> handler);
From source file:app.Main.java
License:Apache License
public static void main(String... args) throws Throwable { Vertx vertx = Vertx.vertx(); TcpEventBusBridge bridge = TcpEventBusBridge.create(vertx, new BridgeOptions().addInboundPermitted(new PermittedOptions().setAddressRegex("sample.*")) .addOutboundPermitted(new PermittedOptions().setAddressRegex("sample.*"))); vertx.eventBus().consumer("sample.dumb.inbox", message -> { JsonObject body = (JsonObject) message.body(); System.out.println(body.encodePrettily()); });//ww w. ja va2 s . co m MessageProducer<Object> tickPublisher = vertx.eventBus().publisher("sample.clock.ticks"); vertx.setPeriodic(1000L, id -> { tickPublisher.send(new JsonObject().put("tick", id)); }); vertx.eventBus().consumer("sample.echo", message -> { JsonObject body = (JsonObject) message.body(); System.out.println("Echoing: " + body.encodePrettily()); message.reply(body); }); bridge.listen(7000, result -> { if (result.failed()) { throw new RuntimeException(result.cause()); } else { System.out.println("TCP Event Bus bridge running on port 7000"); } }); }
From source file:cm.study.vertx.database.WikiDatabaseServiceVertxProxyHandler.java
License:Apache License
public WikiDatabaseServiceVertxProxyHandler(Vertx vertx, WikiDatabaseService service, boolean topLevel, long timeoutSeconds) { this.vertx = vertx; this.service = service; this.timeoutSeconds = timeoutSeconds; try {//from w w w . j a va 2 s .c o m this.vertx.eventBus().registerDefaultCodec(ServiceException.class, new ServiceExceptionMessageCodec()); } catch (IllegalStateException ex) { } if (timeoutSeconds != -1 && !topLevel) { long period = timeoutSeconds * 1000 / 2; if (period > 10000) { period = 10000; } this.timerID = vertx.setPeriodic(period, this::checkTimedOut); } else { this.timerID = -1; } accessed(); }
From source file:com.appdocker.iop.InternetOfPeopleServiceVertxProxyHandler.java
License:Apache License
public InternetOfPeopleServiceVertxProxyHandler(Vertx vertx, InternetOfPeopleService service, boolean topLevel, long timeoutSeconds) { this.vertx = vertx; this.service = service; this.timeoutSeconds = timeoutSeconds; try {/*from w w w .j ava 2s . c o m*/ this.vertx.eventBus().registerDefaultCodec(ServiceException.class, new ServiceExceptionMessageCodec()); } catch (IllegalStateException ex) { } if (timeoutSeconds != -1 && !topLevel) { long period = timeoutSeconds * 1000 / 2; if (period > 10000) { period = 10000; } this.timerID = vertx.setPeriodic(period, this::checkTimedOut); } else { this.timerID = -1; } accessed(); }
From source file:com.diabolicallabs.process.manager.service.KnowledgeServiceFactoryVertxProxyHandler.java
License:Apache License
public KnowledgeServiceFactoryVertxProxyHandler(Vertx vertx, KnowledgeServiceFactory service, boolean topLevel, long timeoutSeconds) { this.vertx = vertx; this.service = service; this.timeoutSeconds = timeoutSeconds; try {//from ww w.j a va2 s . c o m this.vertx.eventBus().registerDefaultCodec(ServiceException.class, new ServiceExceptionMessageCodec()); } catch (IllegalStateException ex) { } if (timeoutSeconds != -1 && !topLevel) { long period = timeoutSeconds * 1000 / 2; if (period > 10000) { period = 10000; } this.timerID = vertx.setPeriodic(period, this::checkTimedOut); } else { this.timerID = -1; } accessed(); }
From source file:com.diabolicallabs.process.manager.service.KnowledgeServiceVertxProxyHandler.java
License:Apache License
public KnowledgeServiceVertxProxyHandler(Vertx vertx, KnowledgeService service, boolean topLevel, long timeoutSeconds) { this.vertx = vertx; this.service = service; this.timeoutSeconds = timeoutSeconds; try {/*from ww w. j av a2s. c o m*/ this.vertx.eventBus().registerDefaultCodec(ServiceException.class, new ServiceExceptionMessageCodec()); } catch (IllegalStateException ex) { } if (timeoutSeconds != -1 && !topLevel) { long period = timeoutSeconds * 1000 / 2; if (period > 10000) { period = 10000; } this.timerID = vertx.setPeriodic(period, this::checkTimedOut); } else { this.timerID = -1; } accessed(); }
From source file:com.diabolicallabs.process.manager.service.ProcessInstanceServiceVertxProxyHandler.java
License:Apache License
public ProcessInstanceServiceVertxProxyHandler(Vertx vertx, ProcessInstanceService service, boolean topLevel, long timeoutSeconds) { this.vertx = vertx; this.service = service; this.timeoutSeconds = timeoutSeconds; try {/* www . ja v a 2s .c om*/ this.vertx.eventBus().registerDefaultCodec(ServiceException.class, new ServiceExceptionMessageCodec()); } catch (IllegalStateException ex) { } if (timeoutSeconds != -1 && !topLevel) { long period = timeoutSeconds * 1000 / 2; if (period > 10000) { period = 10000; } this.timerID = vertx.setPeriodic(period, this::checkTimedOut); } else { this.timerID = -1; } accessed(); }
From source file:com.diabolicallabs.process.manager.service.ProcessServiceVertxProxyHandler.java
License:Apache License
public ProcessServiceVertxProxyHandler(Vertx vertx, ProcessService service, boolean topLevel, long timeoutSeconds) { this.vertx = vertx; this.service = service; this.timeoutSeconds = timeoutSeconds; try {/* w ww. j a va2s . c o m*/ this.vertx.eventBus().registerDefaultCodec(ServiceException.class, new ServiceExceptionMessageCodec()); } catch (IllegalStateException ex) { } if (timeoutSeconds != -1 && !topLevel) { long period = timeoutSeconds * 1000 / 2; if (period > 10000) { period = 10000; } this.timerID = vertx.setPeriodic(period, this::checkTimedOut); } else { this.timerID = -1; } accessed(); }
From source file:com.diabolicallabs.process.manager.service.RuleServiceVertxProxyHandler.java
License:Apache License
public RuleServiceVertxProxyHandler(Vertx vertx, RuleService service, boolean topLevel, long timeoutSeconds) { this.vertx = vertx; this.service = service; this.timeoutSeconds = timeoutSeconds; try {/* www .j a va 2s . c o m*/ this.vertx.eventBus().registerDefaultCodec(ServiceException.class, new ServiceExceptionMessageCodec()); } catch (IllegalStateException ex) { } if (timeoutSeconds != -1 && !topLevel) { long period = timeoutSeconds * 1000 / 2; if (period > 10000) { period = 10000; } this.timerID = vertx.setPeriodic(period, this::checkTimedOut); } else { this.timerID = -1; } accessed(); }
From source file:com.diabolicallabs.process.manager.service.TaskServiceVertxProxyHandler.java
License:Apache License
public TaskServiceVertxProxyHandler(Vertx vertx, TaskService service, boolean topLevel, long timeoutSeconds) { this.vertx = vertx; this.service = service; this.timeoutSeconds = timeoutSeconds; try {//from www . j a v a 2 s . c om this.vertx.eventBus().registerDefaultCodec(ServiceException.class, new ServiceExceptionMessageCodec()); } catch (IllegalStateException ex) { } if (timeoutSeconds != -1 && !topLevel) { long period = timeoutSeconds * 1000 / 2; if (period > 10000) { period = 10000; } this.timerID = vertx.setPeriodic(period, this::checkTimedOut); } else { this.timerID = -1; } accessed(); }
From source file:com.edgar.vertx.service.discovery.eventbus.MyServiceVertxProxyHandler.java
License:Apache License
public MyServiceVertxProxyHandler(Vertx vertx, MyService service, boolean topLevel, long timeoutSeconds) { this.vertx = vertx; this.service = service; this.timeoutSeconds = timeoutSeconds; try {/*from w ww . ja v a 2 s .c om*/ this.vertx.eventBus().registerDefaultCodec(ServiceException.class, new ServiceExceptionMessageCodec()); } catch (IllegalStateException ex) { } if (timeoutSeconds != -1 && !topLevel) { long period = timeoutSeconds * 1000 / 2; if (period > 10000) { period = 10000; } this.timerID = vertx.setPeriodic(period, this::checkTimedOut); } else { this.timerID = -1; } accessed(); }