Note that NATS clustered servers have a forwarding limit of one hop. This means that each gnatsd instance will only forward messages that it has received from a client to the immediately adjacent gnatsd instances to which it has routes. Messages received from a route will only be distributed to local clients. Therefore a full mesh cluster, or complete graph, is recommended for NATS to function as intended and as described throughout the documentation.
假设我有一个包含 3 个节点的 NATS 集群:A -> B -> C(->
表示路由)。请您告诉我在以下情况下 NATS 客户端会发生什么情况:
- 发送到节点 A 的消息
- 节点 A 在将消息传递给节点 B 之前突然终止
提前致谢
最佳答案
在您描述的情况下,消息将被删除。
核心 NATS 提供“最多一次”的传送保证,因此如果您不能容忍丢失消息,您的应用程序需要检测消息从未到达其目的地并重新发送消息。您可以使用请求/回复模式从超时中检测到这一点,或者对丢失的消息实现您自己的补救类型。
或者,您可以使用 NATS 流,它提供基于日志的持久性并位于 NATS 之上。它将保证消息将被传递“至少一次”。
关于nats.io - 了解 NATS 集群,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48293735/