Spring AMQP:[RabbitTemplate] 执行 RabbitTemplate ReturnCallback 时不会调用 Hystrix 回退
Spring AMQP : [RabbitTemplate] Hystrix fallback is not getting invoked when RabbitTemplate ReturnCallback is executed
当我的消息未传送到 RabbitMQ 服务器时,我正在使用 hystrix 来处理回退场景。当 RabbitMQ 服务器关闭时(因为抛出 AMQPException),我的回退被调用。
如果代理无法 accept/route 消息,则调用 returnCallback/returnConfirm(带 nack)。
我的理解是 RabbitTemplate returnCallbacks/returnConfirms 将在与 Hystrix 线程不同的线程中执行。
是否可以在这些场景中抛出异常,以便执行 Hystrix 回退?
我已经提到了这些问题:
非常感谢任何处理这种情况的指示。
没有; returns是完全异步的;即使您启用交易 - 从 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)
*),你将在提交时得到一个异常,但是发布到一个没有可路由队列的交换器永远不会得到一个异常(只有一个异步return回调)。
- 启用事务对于所有操作来说都非常昂贵,因此如果您想抓住这种特殊情况,请仔细考虑
当我的消息未传送到 RabbitMQ 服务器时,我正在使用 hystrix 来处理回退场景。当 RabbitMQ 服务器关闭时(因为抛出 AMQPException),我的回退被调用。
如果代理无法 accept/route 消息,则调用 returnCallback/returnConfirm(带 nack)。
我的理解是 RabbitTemplate returnCallbacks/returnConfirms 将在与 Hystrix 线程不同的线程中执行。
是否可以在这些场景中抛出异常,以便执行 Hystrix 回退?
我已经提到了这些问题:
非常感谢任何处理这种情况的指示。
没有; returns是完全异步的;即使您启用交易 - 从 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)
*),你将在提交时得到一个异常,但是发布到一个没有可路由队列的交换器永远不会得到一个异常(只有一个异步return回调)。
- 启用事务对于所有操作来说都非常昂贵,因此如果您想抓住这种特殊情况,请仔细考虑