Search in sources :

Example 1 with ClusteredMessage

use of io.vertx.core.eventbus.impl.clustered.ClusteredMessage in project vert.x by eclipse.

the class HandlerRegistration method deliver.

private void deliver(Handler<Message<T>> theHandler, Message<T> message) {
    // Handle the message outside the sync block
    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=473714
    checkNextTick();
    boolean local = true;
    if (message instanceof ClusteredMessage) {
        // A bit hacky
        ClusteredMessage cmsg = (ClusteredMessage) message;
        if (cmsg.isFromWire()) {
            local = false;
        }
    }
    String creditsAddress = message.headers().get(MessageProducerImpl.CREDIT_ADDRESS_HEADER_NAME);
    if (creditsAddress != null) {
        eventBus.send(creditsAddress, 1);
    }
    try {
        metrics.beginHandleMessage(metric, local);
        theHandler.handle(message);
        metrics.endHandleMessage(metric, null);
    } catch (Exception e) {
        log.error("Failed to handleMessage", e);
        metrics.endHandleMessage(metric, e);
        throw e;
    }
}
Also used : ClusteredMessage(io.vertx.core.eventbus.impl.clustered.ClusteredMessage) ReplyException(io.vertx.core.eventbus.ReplyException)

Aggregations

ReplyException (io.vertx.core.eventbus.ReplyException)1 ClusteredMessage (io.vertx.core.eventbus.impl.clustered.ClusteredMessage)1