RabbitMQ 发布者如何确认工作?
How does RabbitMQ publisher confirms work?
我已经阅读了 rabbitmq 文档,
https://www.rabbitmq.com/confirms.html#publisher-confirms
Using standard AMQP 0-9-1, the only way to guarantee that a message
isn't lost is by using transactions -- make the channel transactional
then for each message or set of messages publish, commit. In this
case, transactions are unnecessarily heavyweight and decrease
throughput by a factor of 250. To remedy this, a confirmation
mechanism was introduced. It mimics the consumer acknowledgements
mechanism already present in the protocol.
To enable confirms, a client sends the confirm.select method.
Depending on whether no-wait was set or not, the broker may respond
with a confirm.select-ok. Once the confirm.select method is used on a
channel, it is said to be in confirm mode. A transactional channel
cannot be put into confirm mode and once a channel is in confirm mode,
it cannot be made transactional.
目前我正在使用 spring-rabbit 库的 RabbitTemplate.convertAndSend 发送消息。
我正在使用事务通道将消息发布到 rabbitmq,根据文档,它的速度较慢,我可以通过使用 publisher-confirm 来提高吞吐量。
不过我不是很清楚。
如果我想启用确认,那么需要进行哪些更改以及如何处理异常?
我的重审机制是什么?
该发布者确认以异步方式工作吗?
事务是否同步工作?
非常感谢任何建议。
如果您等待每个单独发送的确认,使用发布者确认不会显着提高交易性能。如果您发送很多消息并稍后等待确认,它们会有很大帮助。
事务是同步的。确认是完全异步的。
启用确认后,您会向模板提供一个回调,该回调将在收到确认时调用。您将相关数据添加到发送中,回调中提供了相关数据,因此您可以确定此确认是针对哪个发送。此外,相关数据(在最新版本中)提供了一个 Future<?>
,您可以等待它以同步方式接收确认。
这是您处理任何异常的地方。
希望对您有所帮助。
在 samples repo but it was created before the future was added to the CorrelationData
. That will be fixed soon 中有一个确认和 returns 示例 Spring 引导应用程序。
关联数据可以包含原始消息,启用重试。
我已经阅读了 rabbitmq 文档, https://www.rabbitmq.com/confirms.html#publisher-confirms
Using standard AMQP 0-9-1, the only way to guarantee that a message isn't lost is by using transactions -- make the channel transactional then for each message or set of messages publish, commit. In this case, transactions are unnecessarily heavyweight and decrease throughput by a factor of 250. To remedy this, a confirmation mechanism was introduced. It mimics the consumer acknowledgements mechanism already present in the protocol.
To enable confirms, a client sends the confirm.select method. Depending on whether no-wait was set or not, the broker may respond with a confirm.select-ok. Once the confirm.select method is used on a channel, it is said to be in confirm mode. A transactional channel cannot be put into confirm mode and once a channel is in confirm mode, it cannot be made transactional.
目前我正在使用 spring-rabbit 库的 RabbitTemplate.convertAndSend 发送消息。 我正在使用事务通道将消息发布到 rabbitmq,根据文档,它的速度较慢,我可以通过使用 publisher-confirm 来提高吞吐量。
不过我不是很清楚。
如果我想启用确认,那么需要进行哪些更改以及如何处理异常? 我的重审机制是什么? 该发布者确认以异步方式工作吗? 事务是否同步工作?
非常感谢任何建议。
如果您等待每个单独发送的确认,使用发布者确认不会显着提高交易性能。如果您发送很多消息并稍后等待确认,它们会有很大帮助。
事务是同步的。确认是完全异步的。
启用确认后,您会向模板提供一个回调,该回调将在收到确认时调用。您将相关数据添加到发送中,回调中提供了相关数据,因此您可以确定此确认是针对哪个发送。此外,相关数据(在最新版本中)提供了一个 Future<?>
,您可以等待它以同步方式接收确认。
这是您处理任何异常的地方。
希望对您有所帮助。
在 samples repo but it was created before the future was added to the CorrelationData
. That will be fixed soon 中有一个确认和 returns 示例 Spring 引导应用程序。
关联数据可以包含原始消息,启用重试。