本文整理匯總了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);
}
};
}
示例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()));
}
示例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;
}
}
示例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);
}
示例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())));
}
};
}
示例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()));
}
};
}
示例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");
}
}
示例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));
}
示例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));
}
示例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"));
}
示例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;
}
}