使用rabbitmq客户端Java API保证交付
我想知道处理沟通的最佳方式是什么 错误(例如 RabbitMQ 崩溃或网络问题),与 java API。
我们使用 Channel.basicPublish(...)
方法,我们希望 我们发送给经纪人的每条消息的保证交付。
更具体地说,Java客户端发布中有没有一种机制 API(在消息发送到总线之前)确保 消息将被传递(或者当总线发送一个回调时调用 IOException
)或者我们必须实现这个过程吗?
你会怎么做?
I'd like to know what is the best way to deal with communication
errors (RabbitMQ crash or network problems, for example), with java
API.
We use the Channel.basicPublish(...)
method and we would like to
guaranty delivery for each message we send to the broker.
To be more specific, is there a mechanism in the Java client publish
API (before the message is sent to the bus) that insures that the
message will be delivered (or a callback called when the bus sends anIOException
) or do we have to implement this process?
How would you do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在代理上订阅自己的消息,这似乎过于复杂。正如 RabbitMQ 邮件列表中 Simon MacMullen 的回答所述< /a> (从OP的问题移至此答案)交易是一个选项。:
然而,由于这个答案,一些新选项以轻量级发布者确认的形式提供。官方文档有关于“重”交易方法和较新的流式发布者确认的示例:
https://www.rabbitmq.com/blog/2011/02/10/introducing-publisher-confirms/
You could subscribe to your own messages on the broker, which seems overly complex. As stated by this answer by Simon MacMullen in the RabbitMQ mailing list (moved from OP's question into this answer) transactions are an option.:
Since this answer, however, some new options are available in the form of Lightweight Publisher Confirms. The official documentation has examples on both the "heavy" transaction approach and the newer streamed publisher confirms:
https://www.rabbitmq.com/blog/2011/02/10/introducing-publisher-confirms/
在 RabbitMQ 中,有一个方法 channel.basicAck() 可以让您确认消息。
In RabbitMQ there is a method channel.basicAck() which will give you acknowledgment of the message.