Search in sources :

Example 41 with Vertx

use of io.vertx.core.Vertx in project vert.x by eclipse.

the class StreamsExamples method pump4.

public void pump4(Vertx vertx) {
    NetServer server = vertx.createNetServer(new NetServerOptions().setPort(1234).setHost("localhost"));
    server.connectHandler(sock -> {
        sock.handler(buffer -> {
            sock.write(buffer);
            if (sock.writeQueueFull()) {
                sock.pause();
                sock.drainHandler(done -> {
                    sock.resume();
                });
            }
        });
    }).listen();
}
Also used : NetServerOptions(io.vertx.core.net.NetServerOptions) Buffer(io.vertx.core.buffer.Buffer) NetServer(io.vertx.core.net.NetServer) Vertx(io.vertx.core.Vertx) Pump(io.vertx.core.streams.Pump) Handler(io.vertx.core.Handler) NetSocket(io.vertx.core.net.NetSocket) NetServerOptions(io.vertx.core.net.NetServerOptions) NetServer(io.vertx.core.net.NetServer)

Example 42 with Vertx

use of io.vertx.core.Vertx in project yyl_example by Relucent.

the class HelloVertxVerticle method main.

public static void main(String[] args) throws IOException {
    Vertx vertx = Vertx.vertx();
    vertx.deployVerticle(HelloVertxVerticle.class.getName());
}
Also used : Vertx(io.vertx.core.Vertx)

Example 43 with Vertx

use of io.vertx.core.Vertx in project java-chassis by ServiceComb.

the class AbstractClientPool method create.

public void create() {
    // 这里面是同步接口,且好像直接在事件线程中用,保险起见,先使用独立的vertx实例
    Vertx vertx = VertxUtils.getOrCreateVertxByName("registry", null);
    HttpClientOptions httpClientOptions = createHttpClientOptions();
    DeploymentOptions deployOptions = VertxUtils.createClientDeployOptions(this.clientMgr, ServiceRegistryConfig.INSTANCE.getWorkerPoolSize(), 1, httpClientOptions);
    try {
        VertxUtils.blockDeploy(vertx, HttpClientVerticle.class, deployOptions);
    } catch (InterruptedException e) {
        LOGGER.error("deploy a registry verticle failed, {}", e.getMessage());
    }
}
Also used : DeploymentOptions(io.vertx.core.DeploymentOptions) Vertx(io.vertx.core.Vertx) HttpClientOptions(io.vertx.core.http.HttpClientOptions)

Aggregations

Vertx (io.vertx.core.Vertx)43 Test (org.junit.Test)17 VertxOptions (io.vertx.core.VertxOptions)11 Buffer (io.vertx.core.buffer.Buffer)10 Handler (io.vertx.core.Handler)8 NetSocket (io.vertx.core.net.NetSocket)7 Pump (io.vertx.core.streams.Pump)7 CountDownLatch (java.util.concurrent.CountDownLatch)7 DeploymentOptions (io.vertx.core.DeploymentOptions)6 VertxInternal (io.vertx.core.impl.VertxInternal)6 NetServer (io.vertx.core.net.NetServer)6 NetServerOptions (io.vertx.core.net.NetServerOptions)6 JsonObject (io.vertx.core.json.JsonObject)5 Launcher (io.vertx.core.Launcher)4 RunCommandTest (io.vertx.core.impl.launcher.commands.RunCommandTest)4 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 AtomicReference (java.util.concurrent.atomic.AtomicReference)4 AbstractVerticle (io.vertx.core.AbstractVerticle)3 AsyncResult (io.vertx.core.AsyncResult)3