Example usage for io.vertx.core.eventbus Message fail

List of usage examples for io.vertx.core.eventbus Message fail

Introduction

In this page you can find the example usage for io.vertx.core.eventbus Message fail.

Prototype

default void fail(int failureCode, String message) 

Source Link

Document

Signal to the sender that processing of this message failed.

Usage

From source file:net.kuujo.vertigo.instance.impl.ComponentInstanceImpl.java

License:Apache License

@Override
public void handle(Message<Object> message) {
    String action = message.headers().get(ACTION_HEADER);
    if (action == null) {
        input.handle(message);/*from w ww. j a  v  a2s  .c o m*/
    } else {
        switch (action) {
        case MESSAGE_ACTION:
            input.handle(message);
            break;
        case ACK_ACTION:
        case FAIL_ACTION:
        case PAUSE_ACTION:
        case RESUME_ACTION:
            output.handle(message);
            break;
        default:
            message.fail(ReplyFailure.RECIPIENT_FAILURE.toInt(), String.format("Invalid action %s", action));
        }
    }
}

From source file:org.eclipse.hono.authentication.impl.BaseAuthenticationService.java

License:Open Source License

private void replyWithError(final Message<JsonObject> request, final int errorCode, final String message) {
    request.fail(errorCode, message);
}

From source file:org.eclipse.hono.service.auth.BaseAuthenticationService.java

License:Open Source License

private void processMessage(final Message<JsonObject> message) {
    final JsonObject body = message.body();
    authenticate(body, validation -> {
        if (validation.succeeded()) {
            message.reply(AuthenticationConstants.getAuthenticationReply(validation.result().getToken()));
        } else {/*from w  w  w  .  ja va 2  s.  c o m*/
            message.fail(ERROR_CODE_AUTHENTICATION_FAILED, validation.cause().getMessage());
        }
    });
}

From source file:org.eclipse.hono.service.credentials.BaseCredentialsService.java

License:Open Source License

private void reply(final Message<JsonObject> request, final AsyncResult<CredentialsResult<JsonObject>> result) {

    if (result.succeeded()) {
        reply(request, result.result());
    } else {//from   w  ww .  j  av a  2s .  com
        request.fail(HttpURLConnection.HTTP_INTERNAL_ERROR, "cannot process credentials request");
    }
}

From source file:org.eclipse.hono.service.registration.BaseRegistrationService.java

License:Open Source License

private void reply(final Message<JsonObject> request, final AsyncResult<RegistrationResult> result) {

    if (result.succeeded()) {
        reply(request, result.result());
    } else {/*w w  w .j  a  v a2  s  . c  o  m*/
        request.fail(HTTP_INTERNAL_ERROR, "cannot process registration request");
    }
}

From source file:org.entcore.workspace.service.WorkspaceService.java

License:Open Source License

public void copyDocument(final Message<JsonObject> message) {
    emptySize(message.body().getJsonObject("user").getString("userId"), new Handler<Long>() {
        @Override// ww w  .  j ava  2  s .  c o  m
        public void handle(Long emptySize) {
            copyFile(message.body(), documentDao, emptySize, new Handler<JsonObject>() {
                @Override
                public void handle(JsonObject res) {
                    if ("ok".equals(res.getString("status")))
                        message.reply(res);
                    else
                        message.fail(500, res.getString("status"));
                }
            });
        }
    });
}

From source file:org.hawkular.apm.examples.vertx.opentracing.accountmanager.AccountManagerVerticle.java

License:Apache License

private void sendError(int statusCode, String text, Message<JsonObject> message, Span span) {
    logger.warning("Failing message");
    message.fail(statusCode, text);
    if (span != null) {
        span.setTag("fault", text == null ? Integer.toString(statusCode) : text);
    }/*from  w  ww  .  j av  a  2s.c o m*/
}

From source file:org.hawkular.apm.examples.vertx.opentracing.AccountManager.java

License:Apache License

private void sendError(int statusCode, String text, Message<JsonObject> message, Span span) {
    message.fail(statusCode, text);
    if (span != null) {
        span.setTag("fault", text == null ? Integer.toString(statusCode) : text);
    }// w  w  w .  ja  va2 s  . c om
}

From source file:org.hawkular.apm.examples.vertx.opentracing.inventorymanager.InventoryManagerVerticle.java

License:Apache License

void sendError(int statusCode, String text, Message<JsonObject> message, Span span) {
    message.fail(statusCode, text);
    if (span != null) {
        span.setTag("fault", text == null ? Integer.toString(statusCode) : text);
    }/*w w w  . j  a v  a  2 s .  co  m*/
}

From source file:pt.davidafsilva.slacker.api.AbstractSlackerExecutor.java

License:Open Source License

/**
 * Handles an incoming request from the event bus
 *
 * @param request the request message to be handled
 *///from  www . j  a v a 2s .c o m
private void handleExecutorEvent(final Message<SlackerRequest> request) {
    LOGGER.info("<=<= receiving incoming request <=<=");
    LOGGER.debug(request);

    // execute the request handling asynchronously
    context.runOnContext(a -> {
        final Future<SlackerResponse> future = futureFactory.future();
        execute(request.body(), future);
        future.setHandler(handler -> {
            if (handler.succeeded()) {
                LOGGER.info("=>=> successfully handled request =>=>");
                LOGGER.debug(handler.result());
                request.reply(handler.result(),
                        new DeliveryOptions().setCodecName(SlackerResponseMessageCodec.NAME));
            } else {
                request.fail(ResultCode.ERROR.ordinal(), handler.cause().getMessage());
                LOGGER.error("failed to handle request", handler.cause());
            }
        });
    });
}