使用rabbitmq客户端Java API保证交付

发布于 2024-09-27 01:46:59 字数 266 浏览 4 评论 0原文

我想知道处理沟通的最佳方式是什么 错误(例如 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 an
IOException) or do we have to implement this process?

How would you do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

素年丶 2024-10-04 01:46:59

您可以在代理上订阅自己的消息,这似乎过于复杂。正如 RabbitMQ 邮件列表中 Simon MacMullen 的回答所述< /a> (从OP的问题移至此答案)交易是一个选项。:

目前,您可以保证发布的唯一方法
through是在交易内部发布——当交易
提交完成消息在磁盘上(假设持久队列/
持久消息)。但这有点重量级。在
未来我们打算引入流媒体发布者 ACK 来实现同样的功能
以更加异步的方式工作。

然而,由于这个答案,一些新选项以轻量级发布者确认的形式提供。官方文档有关于“重”交易方法和较新的流式发布者确认的示例:

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.:

At the moment the only way you can guarantee that a publish has gone
through is to publish inside a transaction - when the transaction
commit completes the message is on disk (assuming durable queue /
persistent message). This is a little heavyweight though. In the
future we intend to introduce streaming publisher ACKs to do the same
job in a more async way.

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/

残花月 2024-10-04 01:46:59

在 RabbitMQ 中,有一个方法 channel.basicAck() 可以让您确认消息。

In RabbitMQ there is a method channel.basicAck() which will give you acknowledgment of the message.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文