在NSQ中确认消息
我是 NSQ 的新手,想知道是否可以确认消息已被消耗(就像在 Google PubSub 中一样)。我正在使用 Golang,并在浏览 NSQ 文档时(https://github.com/nsqio/nsq/blob/v1.2.1/nsqd/channel.go#L350)我找到了方法FinishMessage
根据其注释,它应该成功丢弃正在传输的消息
。这是否就等于承认了?如果一条消息在 NSQ 中没有被确认,如何确保它一旦被消费就消失了,这样就不会被再次消费?
谢谢
I'm new to NSQ and was wondering whether it is possible to acknowledge that a message was consumed (just like in Google PubSub). I'm using Golang, and while going through the NSQ documentation (https://github.com/nsqio/nsq/blob/v1.2.1/nsqd/channel.go#L350) I've found the method FinishMessage
which according to its comment, it's supposed to successfully discards an in-flight message
. Would that be considered the same as acknowledged? If a message is not acknowledged in NSQ, how is it ensured it's gone once consumed so it won't be consumed over again?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
NSQ 在将消息发送给消费者后自动从队列中删除消息。如果在设置的超时后消费者没有响应,则自动重新排队消息。
是的,根据您使用的编程语言客户端,您必须发送“完成”。
这是 Golang 的文档
https://pkg.go.dev/github.com/nsqio/ go-nsq#Finish
但由于 NSQ 的设计方式,如果预期操作不成功,您必须重新排队来自应用程序的消息。
这是他们网站的摘录
您可以在此处阅读更多信息:https://nsq.io /overview/design.html
希望我的回答对您有所帮助。
NSQ automatically removes a message from the queue after sending it to a consumer. And automatically re-queues the message if there is no response from the consumer after a set timeout.
And yes, depending on which programming language client you are using you have to send 'finish'.
Here are the docs for Golang
https://pkg.go.dev/github.com/nsqio/go-nsq#Finish
But because of the way NSQ is designed you have to re-queue a message from your app if the intended action was not successful.
Here is an excerpt from their website
You can read more here: https://nsq.io/overview/design.html
Hope my answer helps you.