纳特斯流程一次交货一次
我想通过NATS Jetstream实现一次一次交付系统。文档说Jetstream具有此选项,但是没有有关其工作方式以及客户如何实现此功能的示例或详细信息。我知道在出版商方面,我们可以在创建流时设置MSGID并指定重复窗口,但是消费者端呢?
I want to implement an exactly once delivery system with Nats Jetstream. Documentation says that Jetstream has this option, but there is no samples or details about that how it's work and how clients can implement this. I know that in publisher side we can set MsgId and specify duplication window when creating Stream, but what about consumer side?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是 noreferrer“>确切的企业交付)的文档。这有点不当,因为实际所需的内容(以及此功能提供的内容)是恰好是处理。
正如您指出的那样,它是服务器收到已发布的消息时服务器的结合,以及通过已接收消息的订阅(如有必要的必要)进行订阅的A double ACK 调用。
这是一个示例(对于简洁而省略了多余的错误处理)。使用启用Jetstream启动服务器:
nats-server -js
,然后运行此代码(假设Nats.go v1.16+)。值得注意的是,如果
acksync
确实失败(可以从中返回错误),则在此代码上再次重试ACK,直到收到响应。来自客户的冗余ACK是一个无障碍。Here are the docs for exactly-once delivery. This is a bit of a misnomer since what is actually needed (and what this feature provides) is exactly-once processing.
As you point out, it is a combination of de-duplication by the server when receiving a published message as well as a double ack call by the subscription that had received the message (plus retries if necessary).
Here is an example (excess error handling elided for brevity). Start the server with JetStream enabled:
nats-server --js
and then run this code (it assuming nats.go v1.16+).It is worth noting that if an
AckSync
does fail (an error can be returned from it) then its on this code to retry the ack again until a response is received. A redundant ack from the client is a no-op.