生成的 Vertx Service Proxy 类 中使用了哪种消息通信模式?
Which message communication pattern is used in generated Vertx Service Proxy classes?
有人可以澄清消息通信模式的类型:
- 点对点
- 请求-回复
- Publish/Subscribe
... 用于 Vert.X 服务代理 类 用于 RESTful CRUD 应用程序(它有 4 个与 DatabaseVerticle 通信的 HttpServerVerticles 并且已部署通过 MainVerticle)?
提前谢谢你。
我认为它是 Request-Reply,因为它发送 Http 请求并接收 Http 响应,因为在“Vert.x in action”它指出(在第 3.1.4 章):
If you need message consumers to get back to the entity that sent the event then go for request-reply.
非常感谢help/advice。
TL;DR: Request-Reply
如果您查看服务代理 (https://vertx.io/docs/vertx-service-proxy/java/) 的文档,您会在开始时看到它使您免于执行以下“boiler-plate”代码:
JsonObject message = new JsonObject();
message.put("collection", "mycollection")
.put("document", new JsonObject().put("name", "tim"));
DeliveryOptions options = new DeliveryOptions().addHeader("action", "save");
vertx.eventBus().request("database-service-address", message, options, res2 -> {
if (res2.succeeded()) {
// done
} else {
// failure
}
});
同样来自同一个 link:
A service is described with a Java interface containing methods
following the async pattern. Under the hood, messages are sent on the event bus to invoke the service and get the response back
. But for
ease of use, it generates a proxy that you can invoke directly (using
the API from the service interface).
有人可以澄清消息通信模式的类型:
- 点对点
- 请求-回复
- Publish/Subscribe ... 用于 Vert.X 服务代理 类 用于 RESTful CRUD 应用程序(它有 4 个与 DatabaseVerticle 通信的 HttpServerVerticles 并且已部署通过 MainVerticle)? 提前谢谢你。
我认为它是 Request-Reply,因为它发送 Http 请求并接收 Http 响应,因为在“Vert.x in action”它指出(在第 3.1.4 章):
If you need message consumers to get back to the entity that sent the event then go for request-reply.
非常感谢help/advice。
TL;DR: Request-Reply
如果您查看服务代理 (https://vertx.io/docs/vertx-service-proxy/java/) 的文档,您会在开始时看到它使您免于执行以下“boiler-plate”代码:
JsonObject message = new JsonObject();
message.put("collection", "mycollection")
.put("document", new JsonObject().put("name", "tim"));
DeliveryOptions options = new DeliveryOptions().addHeader("action", "save");
vertx.eventBus().request("database-service-address", message, options, res2 -> {
if (res2.succeeded()) {
// done
} else {
// failure
}
});
同样来自同一个 link:
A service is described with a Java interface containing methods following the async pattern. Under the hood,
messages are sent on the event bus to invoke the service and get the response back
. But for ease of use, it generates a proxy that you can invoke directly (using the API from the service interface).