发送消息到任意虚拟主机/与 RabbitMQ/Spring AMQP 交换

问题描述:

我使用 RabbitMQSpring AMQP 发送消息.

I use RabbitMQ and Spring AMQP to send messages.

我有这个片段:

rabbitTemplate.convertAndSend(exchange, key, object);

这在我操作单个 VHOST 时有效.

This works when I operate on a single VHOST.

我必须从 1 个队列接收消息并将它们重新发送到 N 个交换机(在许多不同的 VHOST 上).我如何在 Spring AMQP (ver 1.2) 中做到这一点?

I have to receive messages from 1 queue and resend them to N exchanges (on many different VHOSTs). How can I do it in Spring AMQP (ver 1.2)?

有什么比在我的 xml 上下文中手动定义 (对于每个 VHOST)和相关元素更好的了?

Is there anything better than manually defined <rabbit:connection-factory> (for each VHOST) and related elements in my xml context?

我们在 1.3 中添加了对此的支持.请参阅 参考手册中的路由连接工厂.

We added support for that in 1.3. See Routing Connection Factory in the reference manual.

这不是任意的,但您可以随时更新地图以添加新目标.

It's not arbitrary, but you can update the map at any time to add new targets.