gpt4 book ai didi

java - Spring AMQP : [RabbitTemplate] Hystrix fallback is not getting invoked when RabbitTemplate ReturnCallback is executed

转载 作者:行者123 更新时间:2023-11-30 07:09:12 27 4
gpt4 key购买 nike

当我的消息未传递到 RabbitMQ 服务器时,我使用 hystrix 来处理回退场景。当 RabbitMQ 服务器关闭时(抛出 AMQPException ),我的后备将被调用。如果代理无法接受/路由消息,则调用 returnCallback/returnConfirm(with nack)。
我的理解是 RabbitTemplate returnCallbacks/returnConfirms 将在与 Hystrix 线程不同的线程中执行。

在这些场景中是否可以抛出异常以便执行 Hystrix 回退?

我提到了这些问题:Spring AMQP return callback vs retry callback

Spring RabbitTemplate- How to get hold of the published message for NACKs in Publisher confirm mode

非常感谢任何处理这种情况的指针。

最佳答案

没有;返回完全异步;即使您启用交易 - 来自the rabbit mq documentation ...

AMQP does not specify when errors (e.g. lack of permissions, references to unknown exchanges) in transactional basic.publish and basic.ack commands should be detected. RabbitMQ performs the necessary checks immediately (rather than, say, at the time of commit), but note that both basic.publish and basic.ack are asynchronous commands so any errors will be reported back to the client asynchronously.

如果您发布到不存在的交换器(以及setChannelTransacted(true)*),您将在提交时遇到异常,但发布到没有可路由队列的交换器永远不会遇到异常(仅异步返回回调)。

  • 启用事务对于所有操作来说都相当昂贵,因此如果您想捕捉这种特定场景,请仔细考虑

关于java - Spring AMQP : [RabbitTemplate] Hystrix fallback is not getting invoked when RabbitTemplate ReturnCallback is executed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39480898/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com