同时
ConnectionFactory.newConnection(Address[] addrs)
因此
ConnectionFactory.newConnection(
Address.parseAddresses("somehost.com:5672,otherhost.com:5672"))
工作,我想知道是否有一种方法可以传递多个 URI,例如:
ConectionFactory.newConnection("amqps://somehost.com:5671,amqps://otherhost.com:5671")
或者为了允许每个 URI 可能使用不同的客户端证书,首先创建多个 ConnectionFactories,每个具有一个 URI,然后创建一个将这些连接工厂作为输入的 ConnectionFactory。
最佳答案
很确定这是不可能的。 http://www.rabbitmq.com/uri-spec.html
如果您正在尝试实现故障转移,您可能会考虑像心跳这样的东西:https://wiki.archlinux.org/index.php/Simple_IP_Failover_with_Heartbeat
如果您尝试从多个地方读取消息,您可以使用铲子 (http://www.rabbitmq.com/shovel.html) 将来自多个地方的这些消息放入一个队列中并从中读取。
关于具有多个 URI 的 RabbitMQ 连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10282902/