當前位置: 首頁>>代碼示例>>Java>>正文


Java Message.reply方法代碼示例

本文整理匯總了Java中io.vertx.core.eventbus.Message.reply方法的典型用法代碼示例。如果您正苦於以下問題:Java Message.reply方法的具體用法?Java Message.reply怎麽用?Java Message.reply使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.vertx.core.eventbus.Message的用法示例。


在下文中一共展示了Message.reply方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createSetCharHandler

import io.vertx.core.eventbus.Message; //導入方法依賴的package包/類
private Handler<AsyncResult<Set<Character>>> createSetCharHandler(Message msg) {
  return res -> {
    if (res.failed()) {
      if (res.cause() instanceof ServiceException) {
        msg.reply(res.cause());
      } else {
        msg.reply(new ServiceException(-1, res.cause().getMessage()));
      }
    } else {
      JsonArray arr = new JsonArray();
      for (Character chr: res.result()) {
        arr.add((int) chr);
      }
      msg.reply(arr);
    }
  };
}
 
開發者ID:pflima92,項目名稱:jspare-vertx-ms-blueprint,代碼行數:18,代碼來源:NotificationServiceVertxProxyHandler.java

示例2: createListCharHandler

import io.vertx.core.eventbus.Message; //導入方法依賴的package包/類
private Handler<AsyncResult<List<Character>>> createListCharHandler(Message msg) {
  return res -> {
    if (res.failed()) {
      if (res.cause() instanceof ServiceException) {
        msg.reply(res.cause());
      } else {
        msg.reply(new ServiceException(-1, res.cause().getMessage()));
      }
    } else {
      JsonArray arr = new JsonArray();
      for (Character chr: res.result()) {
        arr.add((int) chr);
      }
      msg.reply(arr);
    }
  };
}
 
開發者ID:pflima92,項目名稱:jspare-vertx-ms-blueprint,代碼行數:18,代碼來源:MailServiceVertxProxyHandler.java

示例3: handle

import io.vertx.core.eventbus.Message; //導入方法依賴的package包/類
public void handle(Message<JsonObject> msg) {
  try {
    JsonObject json = msg.body();
    String action = msg.headers().get("action");
    if (action == null) {
      throw new IllegalStateException("action not specified");
    }
    accessed();
    switch (action) {
      case "createNotification": {
        service.createNotification(createHandler(msg));
        break;
      }
      default: {
        throw new IllegalStateException("Invalid action: " + action);
      }
    }
  } catch (Throwable t) {
    msg.reply(new ServiceException(500, t.getMessage()));
    throw t;
  }
}
 
開發者ID:pflima92,項目名稱:jspare-vertx-ms-blueprint,代碼行數:23,代碼來源:NotificationServiceVertxProxyHandler.java

示例4: handle

import io.vertx.core.eventbus.Message; //導入方法依賴的package包/類
public void handle(Message<JsonObject> msg) {
  try {
    JsonObject json = msg.body();
    String action = msg.headers().get("action");
    if (action == null) {
      throw new IllegalStateException("action not specified");
    }
    accessed();
    switch (action) {
      case "getConfiguration": {
        service.getConfiguration((java.lang.String)json.getValue("name"), createHandler(msg));
        break;
      }
      default: {
        throw new IllegalStateException("Invalid action: " + action);
      }
    }
  } catch (Throwable t) {
    msg.reply(new ServiceException(500, t.getMessage()));
    throw t;
  }
}
 
開發者ID:pflima92,項目名稱:jspare-vertx-ms-blueprint,代碼行數:23,代碼來源:ConfigurationProviderVertxProxyHandler.java

示例5: enrichData

import io.vertx.core.eventbus.Message; //導入方法依賴的package包/類
void enrichData(final Message<JsonArray> msg) {
    //array of
    /*
        [
            {target: "name", datapoints: [ [value,ts],[value,ts]] }
        ]
     */
    msg.reply(msg.body()
                 .stream()
                 .parallel()
                 .map(o -> (JsonObject) o)
                 .map(target -> new JsonObject().put("target", target.getString("target") + "_btc")
                                                .put("datapoints",
                                                     adjustByBitcoingPrice(target.getJsonArray("datapoints")))

                 )
                 .collect(toJsonArray()));
}
 
開發者ID:gmuecke,項目名稱:grafana-vertx-datasource,代碼行數:19,代碼來源:BitcoinAdjustedData.java

示例6: handle

import io.vertx.core.eventbus.Message; //導入方法依賴的package包/類
public void handle(Message<JsonObject> msg) {
  try {
    JsonObject json = msg.body();
    String action = msg.headers().get("action");
    if (action == null) {
      throw new IllegalStateException("action not specified");
    }
    accessed();
    switch (action) {
      case "send": {
        service.send(json.getJsonObject("message") == null ? null : new io.vertx.ext.mail.MailMessage(json.getJsonObject("message")), res -> {
          if (res.failed()) {
            if (res.cause() instanceof ServiceException) {
              msg.reply(res.cause());
            } else {
              msg.reply(new ServiceException(-1, res.cause().getMessage()));
            }
          } else {
            msg.reply(res.result() == null ? null : res.result().toJson());
          }
       });
        break;
      }
      default: {
        throw new IllegalStateException("Invalid action: " + action);
      }
    }
  } catch (Throwable t) {
    msg.reply(new ServiceException(500, t.getMessage()));
    throw t;
  }
}
 
開發者ID:pflima92,項目名稱:jspare-vertx-ms-blueprint,代碼行數:33,代碼來源:MailServiceVertxProxyHandler.java

示例7: syncReply

import io.vertx.core.eventbus.Message; //導入方法依賴的package包/類
private void syncReply(final Message<Envelop> message,
                       final Object reference,
                       final String name) {
    // Call the handler
    final Envelop envelop = message.body();
    // Invoke
    final Envelop reply =
            Instance.invoke(reference, name, envelop);
    // Reply Message
    message.reply(reply);
}
 
開發者ID:silentbalanceyh,項目名稱:vertx-zero,代碼行數:12,代碼來源:ZeroHttpWorker.java

示例8: toHandler

import io.vertx.core.eventbus.Message; //導入方法依賴的package包/類
static <T> Handler<AsyncResult<T>> toHandler(
        final Message<Envelop> message
) {
    return handler -> {
        if (handler.succeeded()) {
            message.reply(To.toEnvelop(handler.result()));
        } else {
            // Readible codec for configured information, error flow needed.
            message.reply(Envelop.failure(To.toError(Web.class, handler.cause())));
        }
    };
}
 
開發者ID:silentbalanceyh,項目名稱:vertx-zero,代碼行數:13,代碼來源:Web.java

示例9: createListHandler

import io.vertx.core.eventbus.Message; //導入方法依賴的package包/類
private <T> Handler<AsyncResult<List<T>>> createListHandler(Message msg) {
  return res -> {
    if (res.failed()) {
      if (res.cause() instanceof ServiceException) {
        msg.reply(res.cause());
      } else {
        msg.reply(new ServiceException(-1, res.cause().getMessage()));
      }
    } else {
      msg.reply(new JsonArray(res.result()));
    }
  };
}
 
開發者ID:pflima92,項目名稱:jspare-vertx-ms-blueprint,代碼行數:14,代碼來源:MailServiceVertxProxyHandler.java

示例10: createSetHandler

import io.vertx.core.eventbus.Message; //導入方法依賴的package包/類
private <T> Handler<AsyncResult<Set<T>>> createSetHandler(Message msg) {
  return res -> {
    if (res.failed()) {
      if (res.cause() instanceof ServiceException) {
        msg.reply(res.cause());
      } else {
        msg.reply(new ServiceException(-1, res.cause().getMessage()));
      }
    } else {
      msg.reply(new JsonArray(new ArrayList<>(res.result())));
    }
  };
}
 
開發者ID:pflima92,項目名稱:jspare-vertx-ms-blueprint,代碼行數:14,代碼來源:ConfigurationProviderVertxProxyHandler.java

示例11: findAll

import io.vertx.core.eventbus.Message; //導入方法依賴的package包/類
public void findAll(Message<JsonObject> message) {
    JsonObject query = message.body();
    if (dependencies != null) {
        message.reply(dependencies);
    } else {
        message.fail(500, "Impossible to retrieve dependencies");
    }
}
 
開發者ID:danielpetisme,項目名稱:vertx-forge,代碼行數:9,代碼來源:DependencyService.java

示例12: sendReply

import io.vertx.core.eventbus.Message; //導入方法依賴的package包/類
private void sendReply(final Message<JsonObject> msg, final JsonArray rawResult, final long start) {

        msg.reply(rawResult);
        LOG.info("TIME: response sent after {} ms", (System.currentTimeMillis() - start));
    }
 
開發者ID:gmuecke,項目名稱:grafana-vertx-datasource,代碼行數:6,代碼來源:SplitMergeTimeSeriesVerticle.java

示例13: direct

import io.vertx.core.eventbus.Message; //導入方法依賴的package包/類
@Address("ZUES://DIRECT")
public void direct(final Message<Envelop> data) {
    final JsonObject replied = (data.body().data(0, JsonObject.class));
    data.reply(Envelop.success(replied));
}
 
開發者ID:silentbalanceyh,項目名稱:vertx-zero,代碼行數:6,代碼來源:SpeakAddrWorker.java

示例14: sayHello

import io.vertx.core.eventbus.Message; //導入方法依賴的package包/類
@Address("EXP3://QUEUE/VALIDATE")
public void sayHello(final Message<Envelop> message) {
    final JsonObject data = Rapider.getJson(message);
    Params.start(getClass()).monitor(data).end();
    message.reply(Envelop.success("Response Successfully"));
}
 
開發者ID:silentbalanceyh,項目名稱:vertx-zero,代碼行數:7,代碼來源:SimpleWorker.java

示例15: handle

import io.vertx.core.eventbus.Message; //導入方法依賴的package包/類
public void handle(Message<JsonObject> msg) {
  try {
    JsonObject json = msg.body();
    String action = msg.headers().get("action");
    if (action == null) {
      throw new IllegalStateException("action not specified");
    }
    accessed();
    switch (action) {
      case "getPortfolio": {
        service.getPortfolio(res -> {
          if (res.failed()) {
            if (res.cause() instanceof ServiceException) {
              msg.reply(res.cause());
            } else {
              msg.reply(new ServiceException(-1, res.cause().getMessage()));
            }
          } else {
            msg.reply(res.result() == null ? null : res.result().toJson());
          }
       });
        break;
      }
      case "buy": {
        service.buy(json.getValue("amount") == null ? null : (json.getLong("amount").intValue()), (io.vertx.core.json.JsonObject)json.getValue("quote"), res -> {
          if (res.failed()) {
            if (res.cause() instanceof ServiceException) {
              msg.reply(res.cause());
            } else {
              msg.reply(new ServiceException(-1, res.cause().getMessage()));
            }
          } else {
            msg.reply(res.result() == null ? null : res.result().toJson());
          }
       });
        break;
      }
      case "sell": {
        service.sell(json.getValue("amount") == null ? null : (json.getLong("amount").intValue()), (io.vertx.core.json.JsonObject)json.getValue("quote"), res -> {
          if (res.failed()) {
            if (res.cause() instanceof ServiceException) {
              msg.reply(res.cause());
            } else {
              msg.reply(new ServiceException(-1, res.cause().getMessage()));
            }
          } else {
            msg.reply(res.result() == null ? null : res.result().toJson());
          }
       });
        break;
      }
      case "evaluate": {
        service.evaluate(createHandler(msg));
        break;
      }
      default: {
        throw new IllegalStateException("Invalid action: " + action);
      }
    }
  } catch (Throwable t) {
    msg.reply(new ServiceException(500, t.getMessage()));
    throw t;
  }
}
 
開發者ID:cescoffier,項目名稱:vertx-kubernetes-workshop,代碼行數:65,代碼來源:PortfolioServiceVertxProxyHandler.java


注:本文中的io.vertx.core.eventbus.Message.reply方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。