本文整理匯總了Java中io.vertx.core.Vertx.setPeriodic方法的典型用法代碼示例。如果您正苦於以下問題:Java Vertx.setPeriodic方法的具體用法?Java Vertx.setPeriodic怎麽用?Java Vertx.setPeriodic使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.vertx.core.Vertx
的用法示例。
在下文中一共展示了Vertx.setPeriodic方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: PortfolioServiceVertxProxyHandler
import io.vertx.core.Vertx; //導入方法依賴的package包/類
public PortfolioServiceVertxProxyHandler(Vertx vertx, PortfolioService service, boolean topLevel, long timeoutSeconds) {
this.vertx = vertx;
this.service = service;
this.timeoutSeconds = timeoutSeconds;
try {
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();
}
示例2: MetricsFacade
import io.vertx.core.Vertx; //導入方法依賴的package包/類
public MetricsFacade(Vertx vertx, HttpServer httpServer, int publicationPeriodInMillis) {
this.httpServer = httpServer;
this.metricsService = MetricsService.create(vertx);
logger.info("Scheduling metrics publication every {}ms", publicationPeriodInMillis);
// ensure that the metrics publication does *not* happen on an event loop thread
vertx.setPeriodic(
publicationPeriodInMillis,
event ->
vertx.executeBlocking(
event1 -> {
JsonObject metrics = metricsService.getMetricsSnapshot(httpServer);
if (metrics != null) {
metricsLogger.info(metrics.encode());
}
event1.complete();
},
(Handler<AsyncResult<Void>>)
event12 -> {
// no-op
}));
}
示例3: NotificationServiceVertxProxyHandler
import io.vertx.core.Vertx; //導入方法依賴的package包/類
public NotificationServiceVertxProxyHandler(Vertx vertx, NotificationService service, boolean topLevel, long timeoutSeconds) {
this.vertx = vertx;
this.service = service;
this.timeoutSeconds = timeoutSeconds;
try {
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();
}
開發者ID:pflima92,項目名稱:jspare-vertx-ms-blueprint,代碼行數:20,代碼來源:NotificationServiceVertxProxyHandler.java
示例4: MailServiceVertxProxyHandler
import io.vertx.core.Vertx; //導入方法依賴的package包/類
public MailServiceVertxProxyHandler(Vertx vertx, MailService service, boolean topLevel, long timeoutSeconds) {
this.vertx = vertx;
this.service = service;
this.timeoutSeconds = timeoutSeconds;
try {
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();
}
示例5: ConfigurationProviderVertxProxyHandler
import io.vertx.core.Vertx; //導入方法依賴的package包/類
public ConfigurationProviderVertxProxyHandler(Vertx vertx, ConfigurationProvider service, boolean topLevel, long timeoutSeconds) {
this.vertx = vertx;
this.service = service;
this.timeoutSeconds = timeoutSeconds;
try {
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();
}
開發者ID:pflima92,項目名稱:jspare-vertx-ms-blueprint,代碼行數:20,代碼來源:ConfigurationProviderVertxProxyHandler.java
示例6: async_behavior
import io.vertx.core.Vertx; //導入方法依賴的package包/類
@Test /*(timeout=5000)*/ // <8>
public void async_behavior(TestContext context) { // <1>
Vertx vertx = Vertx.vertx(); // <2>
context.assertEquals("foo", "foo"); // <3>
Async a1 = context.async(); // <4>
Async a2 = context.async(3); // <5>
vertx.setTimer(100, n -> a1.complete()); // <6>
vertx.setPeriodic(100, n -> a2.countDown()); // <7>
}
示例7: main
import io.vertx.core.Vertx; //導入方法依賴的package包/類
public static void main(String[] args) {
Vertx vertx = Vertx.vertx();
vertx.setPeriodic(2000, id -> {
System.out.println("Timer fired with id : " + id);
});
vertx.setPeriodic(5000, id -> {
throw new RuntimeException("I failed in second timer");
});
try {
TimeUnit.SECONDS.sleep(10);
} catch (InterruptedException e) {
}
vertx.close();
}