为什么在 Rabbitmq 中接收消息后如果出现错误,消息不会从队列中删除?

huangapple go评论67阅读模式
英文:

Why message is not deleted in queue if there is a error after receiving a message in Rabbitmq

问题

我正在处理 RabbitMQ。在这个主题上,我是个新手。我有一个成功的发送者和接收者。在这方面我没有问题,但我注意到如果代码出现错误,消息会被卡在队列里。

详细来说,当我从队列中获取消息时,这条消息应该被删除。无论是否出现错误,都不应该有影响。因为队列不能判断这条消息是否被成功处理。队列只负责投递,对吗?那么队列怎么知道程序出错并且需要保留消息呢?😀
所以我一直反复收到相同的消息。

如果你们能帮我了解 RabbitMQ 的基础知识,我将不胜感激。谢谢,祝你们所有人有美好的一天!😀

英文:

I am working on Rabbitmq. I am a newbie in this topic. I have a successful sender and receiver. I have no problem at that but I noticed that if there is a fail in code message stuck in a queue.

If I explain in detail, When I get the message from a queue, the message should be deleted. It should do not matter is there a fail or not. Because queue cant tells this message successfully processed or not. The queue just delivers right? So how the hell queue understands the program that there is a fail in code and keep the message. 为什么在 Rabbitmq 中接收消息后如果出现错误,消息不会从队列中删除?
So I just receive the message again and again.

If u guys help me about the basics of Rabbitmq. I will be glad. Thx Have a good day all of u 为什么在 Rabbitmq 中接收消息后如果出现错误,消息不会从队列中删除?

答案1

得分: 1

消息会保留在队列中,直到收到确认。如果在消息收到确认之前,接收消息的连接发生故障,该消息不会被删除,而会在之后重新投递。

在您的情况下,您可能希望激活自动确认机制

英文:

Messages stay in queues until they are acknowledged, if a connection that was sent a message fails before the message is acknowledged, the message is not deleted and it's redelivered later.

In your case you may want to activate automatic acknowledgement

huangapple
  • 本文由 发表于 2020年7月27日 21:52:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/63116828.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定