<artifactId>vertx-web-client</artifactId> <version>4.5.10</version></dependency>构建全局的 Vertx:通过配置VertxOptions WebClient client ; //全局超时时间 private static final long TimeOut = 3000L; static { //配置vertxOptions 参数 VertxOptions vertxOptions = new VertxOptions(); //The default number of event loop threads public static final int DEFAULT_EVENT_LOOP_POOL_SIZE = 2 * CpuCoreSensor.availableProcessors(); vertxOptions.setEventLoopPoolSize (100); //默认是cpu核心数*2, Vertx vertx = Vertx.vertx(vertxOptions); //配置客户端的配置信息 HttpClientOptions
bigdata.spark.DaoUtil; import com.google.common.collect.Lists; import io.vertx.core.Vertx; import io.vertx.core.VertxOptions max_pool_size", 20) .put("user", "root") .put("password", "password"); VertxOptions vo = new VertxOptions(); vo.setEventLoopPoolSize(10); vo.setWorkerPoolSize(20);
1.1 Vertx对象配置 创建Vertx时能够进行一些配置,例如: Vertx vertx = Vertx.vertx(new VertxOptions().setWorkerPoolSize(40) ); VertxOptions对象有诸多选项以供配置,例如集群(clustering),高可用(high availability),池大小(pool sizes)等等。
dependency> 完整的案例: package org.datastream.AsyncIO; import io.vertx.core.Vertx; import io.vertx.core.VertxOptions RedisOptions(); config.setHost("127.0.0.1"); config.setPort(6379); VertxOptions vo = new VertxOptions(); vo.setEventLoopPoolSize(10); vo.setWorkerPoolSize(20
VertxFactoryImpl.clusteredVertx(VertxOptions options, final Handler<AsyncResult<Vertx>> resultHandler new VertxImpl(options, resultHandler);//创建Vertx实例 } 图1启动集群 在VertxImpl的构造方法中,若需要创建集群,则执行: VertxImpl(VertxOptions 如下: getClusterManager(VertxOptions options) { if (options.isClustered()) { if (options.getClusterManager
io.vertx.core.AsyncResult; import io.vertx.core.Handler; import io.vertx.core.Vertx; import io.vertx.core.VertxOptions root") .put("password", "root") .put("max_pool_size", 20); VertxOptions options = new VertxOptions(); options.setEventLoopPoolSize(10); options.setWorkerPoolSize package cn.it.extend; import io.vertx.core.Vertx; import io.vertx.core.VertxOptions; import io.vertx.redis.RedisClient vo = new VertxOptions(); vo.setEventLoopPoolSize(10); vo.setWorkerPoolSize(20);
VertxOptions options = new VertxOptions(); options.setWorkerPoolSize(20); Vertx vertx2 = Vertx.vertx(
(String[] args) { // 使用DropwizardMetricsOptions配置创建单机Vertx实例 Vertx vertx = Vertx.vertx( new VertxOptions 想了解点这里:http://my.oschina.net/chkui/blog/708639) 首先,需要像下面这样创建一个Vertx实例: Vertx vertx = Vertx.vertx(new VertxOptions