List of usage examples for io.vertx.core.eventbus Message headers
MultiMap headers();
From source file:cm.study.vertx.database.WikiDatabaseServiceVertxProxyHandler.java
License:Apache License
public void handle(Message<JsonObject> msg) { try {/*from ww w. j a va 2s. c o m*/ JsonObject json = msg.body(); String action = msg.headers().get("action"); if (action == null) { throw new IllegalStateException("action not specified"); } accessed(); switch (action) { case "fetchAllPages": { service.fetchAllPages(createHandler(msg)); break; } default: { throw new IllegalStateException("Invalid action: " + action); } } } catch (Throwable t) { msg.reply(new ServiceException(500, t.getMessage())); throw t; } }
From source file:co.runrightfast.vertx.core.eventbus.MessageHeader.java
License:Apache License
public static Optional<String> getMessageId(@NonNull final Message message) { return Optional.ofNullable(message.headers().get(MESSAGE_ID.header)); }
From source file:co.runrightfast.vertx.core.eventbus.MessageHeader.java
License:Apache License
public static Optional<String> getCorrelationId(@NonNull final Message message) { return Optional.ofNullable(message.headers().get(MESSAGE_CORRELATION_ID.header)); }
From source file:co.runrightfast.vertx.core.eventbus.MessageHeader.java
License:Apache License
public static Optional<Instant> getMessageTimestamp(@NonNull final Message message) { return Optional.ofNullable(message.headers().get(MESSAGE_TIMESTAMP.header)).map(Instant::parse); }
From source file:co.runrightfast.vertx.core.eventbus.MessageHeader.java
License:Apache License
public static Optional<String> getReplyToAddress(@NonNull final Message message) { return Optional.ofNullable(message.headers().get(REPLY_TO_ADDRESS.header)); }
From source file:co.runrightfast.vertx.core.eventbus.MessageHeader.java
License:Apache License
public static Optional<String> getFromAddress(@NonNull final Message message) { return Optional.ofNullable(message.headers().get(FROM_ADDRESS.header)); }
From source file:co.runrightfast.vertx.core.eventbus.MessageHeader.java
License:Apache License
public static Optional<Failure> getFailure(@NonNull final Message message) { final String failureJson = message.headers().get(FAILURE.header); if (StringUtils.isNotBlank(failureJson)) { return Optional.of(new Failure(JsonUtils.parse(failureJson))); }// w ww .j a v a2s . c o m return Optional.empty(); }
From source file:co.runrightfast.vertx.demo.testHarness.jmx.DemoMXBeanImpl.java
License:Apache License
void handleGetVerticleDeploymentsResponse(final Message<GetVerticleDeployments.Response> responseMessage) { final GetVerticleDeployments.Response response = responseMessage.body(); final JsonObject json = Json.createObjectBuilder().add("headers", toJsonObject(responseMessage.headers())) .add("body", ProtobufUtils.protobuMessageToJson(response)).build(); log.info(JsonUtils.toVertxJsonObject(json).encodePrettily()); }
From source file:com.appdocker.iop.InternetOfPeopleServiceVertxProxyHandler.java
License:Apache License
public void handle(Message<JsonObject> msg) { try {//from w w w . ja va 2 s .com JsonObject json = msg.body(); String action = msg.headers().get("action"); if (action == null) { throw new IllegalStateException("action not specified"); } accessed(); switch (action) { case "hello": { service.hello((java.lang.String) json.getValue("message"), createHandler(msg)); break; } case "close": { service.close(); close(); break; } default: { throw new IllegalStateException("Invalid action: " + action); } } } catch (Throwable t) { msg.reply(new ServiceException(500, t.getMessage())); throw t; } }
From source file:com.diabolicallabs.process.manager.service.KnowledgeServiceFactoryVertxProxyHandler.java
License:Apache License
public void handle(Message<JsonObject> msg) { try {/*w ww . j a v a2 s. c o m*/ JsonObject json = msg.body(); String action = msg.headers().get("action"); if (action == null) { throw new IllegalStateException("action not specified"); } accessed(); switch (action) { case "getKnowledgeService": { service.getKnowledgeService(res -> { if (res.failed()) { if (res.cause() instanceof ServiceException) { msg.reply(res.cause()); } else { msg.reply(new ServiceException(-1, res.cause().getMessage())); } } else { String proxyAddress = UUID.randomUUID().toString(); ProxyHelper.registerService(KnowledgeService.class, vertx, res.result(), proxyAddress, false, timeoutSeconds); msg.reply(null, new DeliveryOptions().addHeader("proxyaddr", proxyAddress)); } }); break; } default: { throw new IllegalStateException("Invalid action: " + action); } } } catch (Throwable t) { msg.reply(new ServiceException(500, t.getMessage())); throw t; } }