自从1.5(AMQP-507)以来,我一直在使用Spring AMQP实现的"mandatory"消息 . 现在,出于多种目的,我想对这些消息进行"spy",但似乎我不能真正拥有接收这些消息的目标消费者以外的东西(因为这将被视为交付而发送者因此不会通知) . 我是否有任何替代方案(由RabbitMQ本身或Spring AMQP提供)"duplicate"这些消息到另一个队列而不会弄乱EIP(SmartProxy或Wiretap)?
(当然,我的所有队列都被声明为“自动删除”,因此这可以按预期工作,这就是使这更难完成的原因 . )
1 回答
On the client side
你可以使用一个拦截器 . 例如,如果您使用
spring-rabbit
项目中的SimpleMessageListenerContainer
,则可以使用Advice
使用adviceChain
或消息后处理器MessagePostProcessor
.例如using the example given on the main page
On the rabbitmq side
有锤子firehose . 您将收到给定队列中所有消息的副本 .
如果您使用直接交换,您可以将其类型更改为主题交换并使用路由密钥“*”绑定您的复制队列,但它与“强制”语义不兼容“ .