Search in sources :

Example 11 with MessageConsumer

use of io.vertx.core.eventbus.MessageConsumer in project vertx-openshift-it by cescoffier.

the class DistributedRequestReply method setup.

void setup(Handler<AsyncResult<Void>> handler) {
    EventBus eventBus = vertx.eventBus();
    MessageConsumer<String> consumer = createMessageConsumer(eventBus, address);
    consumer.handler(msg -> {
        msg.reply(clusterManager.getNodeID());
    }).completionHandler(ar -> {
        if (ar.succeeded()) {
            handler.handle(Future.succeededFuture());
        } else {
            handler.handle(Future.failedFuture(ar.cause()));
        }
    });
}
Also used : VertxInternal(io.vertx.core.impl.VertxInternal) ConcurrentHashSet(io.vertx.core.impl.ConcurrentHashSet) ClusterManager(io.vertx.core.spi.cluster.ClusterManager) Vertx(io.vertx.core.Vertx) Message(io.vertx.core.eventbus.Message) HttpHeaders(io.vertx.core.http.HttpHeaders) RoutingContext(io.vertx.ext.web.RoutingContext) Future(io.vertx.core.Future) JsonArray(io.vertx.core.json.JsonArray) EventBus(io.vertx.core.eventbus.EventBus) Buffer(io.vertx.core.buffer.Buffer) AsyncResult(io.vertx.core.AsyncResult) Handler(io.vertx.core.Handler) MessageConsumer(io.vertx.core.eventbus.MessageConsumer) EventBus(io.vertx.core.eventbus.EventBus)

Example 12 with MessageConsumer

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

the class NetSocketImpl method unregisterEventBusHandler.

void unregisterEventBusHandler() {
    if (registration != null) {
        MessageConsumer consumer = registration;
        registration = null;
        consumer.unregister();
    }
}
Also used : MessageConsumer(io.vertx.core.eventbus.MessageConsumer)

Example 13 with MessageConsumer

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

the class NetTest method setHandlers.

void setHandlers(NetSocket sock) {
    Handler<Message<Buffer>> resumeHandler = m -> sock.resume();
    MessageConsumer reg = vertx.eventBus().<Buffer>consumer("client_resume").handler(resumeHandler);
    sock.closeHandler(v -> reg.unregister());
}
Also used : HAProxyMessageCompletionHandler(io.vertx.core.net.impl.HAProxyMessageCompletionHandler) CoreMatchers(org.hamcrest.CoreMatchers) NetServerImpl(io.vertx.core.net.impl.NetServerImpl) ChannelInboundHandlerAdapter(io.netty.channel.ChannelInboundHandlerAdapter) Utils(io.vertx.core.impl.Utils) Unpooled(io.netty.buffer.Unpooled) PlatformDependent(io.netty.util.internal.PlatformDependent) TestUtils(io.vertx.test.core.TestUtils) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ReadStream(io.vertx.core.streams.ReadStream) JsonObject(io.vertx.core.json.JsonObject) CheckingSender(io.vertx.test.core.CheckingSender) Logger(io.vertx.core.impl.logging.Logger) VertxHandler(io.vertx.core.net.impl.VertxHandler) ChannelHandlerAdapter(io.netty.channel.ChannelHandlerAdapter) ConnectTimeoutException(io.netty.channel.ConnectTimeoutException) TestLoggerFactory(io.vertx.test.netty.TestLoggerFactory) SSLHandshakeException(javax.net.ssl.SSLHandshakeException) java.util.concurrent(java.util.concurrent) Message(io.vertx.core.eventbus.Message) Trust(io.vertx.test.tls.Trust) ChannelPipeline(io.netty.channel.ChannelPipeline) InetSocketAddress(java.net.InetSocketAddress) io.vertx.core.http(io.vertx.core.http) StandardCharsets(java.nio.charset.StandardCharsets) io.netty.handler.codec.http(io.netty.handler.codec.http) SSLException(javax.net.ssl.SSLException) Certificate(java.security.cert.Certificate) Buffer(io.vertx.core.buffer.Buffer) Cert(io.vertx.test.tls.Cert) MessageConsumer(io.vertx.core.eventbus.MessageConsumer) NetSocketInternal(io.vertx.core.net.impl.NetSocketInternal) HttpVersion(io.netty.handler.codec.http.HttpVersion) java.util(java.util) LoggerFactory(io.vertx.core.impl.logging.LoggerFactory) io.vertx.core(io.vertx.core) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) VertxTestBase(io.vertx.test.core.VertxTestBase) AtomicReference(java.util.concurrent.atomic.AtomicReference) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) SSLSession(javax.net.ssl.SSLSession) ByteBuf(io.netty.buffer.ByteBuf) io.vertx.test.proxy(io.vertx.test.proxy) OutputStreamWriter(java.io.OutputStreamWriter) Assume(org.junit.Assume) VertxInternal(io.vertx.core.impl.VertxInternal) ConcurrentHashSet(io.vertx.core.impl.ConcurrentHashSet) BufferedWriter(java.io.BufferedWriter) HttpMethod(io.netty.handler.codec.http.HttpMethod) FileOutputStream(java.io.FileOutputStream) Test(org.junit.Test) File(java.io.File) Consumer(java.util.function.Consumer) JsonArray(io.vertx.core.json.JsonArray) AtomicLong(java.util.concurrent.atomic.AtomicLong) Rule(org.junit.Rule) TemporaryFolder(org.junit.rules.TemporaryFolder) SSLPeerUnverifiedException(javax.net.ssl.SSLPeerUnverifiedException) MessageConsumer(io.vertx.core.eventbus.MessageConsumer) Message(io.vertx.core.eventbus.Message)

Aggregations

MessageConsumer (io.vertx.core.eventbus.MessageConsumer)13 Buffer (io.vertx.core.buffer.Buffer)9 EventBus (io.vertx.core.eventbus.EventBus)9 VertxInternal (io.vertx.core.impl.VertxInternal)7 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)7 Test (org.junit.Test)7 io.vertx.core (io.vertx.core)6 Future (io.vertx.core.Future)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6 Vertx (io.vertx.core.Vertx)5 CountDownLatch (java.util.concurrent.CountDownLatch)5 AtomicReference (java.util.concurrent.atomic.AtomicReference)5 Consumer (java.util.function.Consumer)5 AsyncResult (io.vertx.core.AsyncResult)4 Handler (io.vertx.core.Handler)4 DatagramSocket (io.vertx.core.datagram.DatagramSocket)4 DeliveryOptions (io.vertx.core.eventbus.DeliveryOptions)4 ReplyFailure (io.vertx.core.eventbus.ReplyFailure)4 io.vertx.core.http (io.vertx.core.http)4 HttpHeaders (io.vertx.core.http.HttpHeaders)4