了解 NATS 集群

Understanding NATS clustering

NATS Server Clustering 节指出:

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 客户端会发生什么:

提前致谢

在您描述的情况下,邮件将被丢弃。

核心 NATS 提供 "at most once" 的传递保证,因此如果您不能容忍丢失消息,您的应用程序需要检测到消息从未到达目的地并重新发送消息。您可以使用 request/reply 模式从超时中检测到这一点,或者对丢失的消息实施您自己的补救类型。

或者,您可以使用 NATS 流,它提供基于日志的持久性并位于 NATS 之上。它将保证消息将被传递 "at least once".