Is there any configuration to connect to queue wit

2019-07-23 09:29发布

问题:

I just want to know if there is configuration property in spring-amqp to auto connect to the hosts given in application property file which has same queue name!

For example, I have around 20 queues that will be used to publish and consume by around 10 small spring boot applications in a VM(server1) and if some things happens to queues/rabbitmq node on server1, then it should connect to same set of queues on server2 (whose host/addresses could be given application.property file - clustered/ non clustered nodes - all methods are fine for me). This could have been solved by Mirroring queue, but they involve performance degradation(transferring to other node and extra network trip by apps on other server whose nodes on which queues doesn't reside)

Not a great programmer now! Please ignore my ignorance! ;)

回答1:

What you are suggesting makes no sense, unless you are willing to lose messages and the queues are configured for auto-deletion.

If that's the case, it will "just work", simply use host1,host2 and, as long as the queues/bindings etc are configured as Spring @Beans, when the connection fails over, the queues will be declared on the new broker.

It doesn't make any sense for non-auto-delete queues since it is possible that messages still exist on the failed broker (and they will be consumed the next time we connect, but now there could be stale messages on the second broker).