I'd like to find out: are there any ways to set up the RabbitMQ mirroring (HA queues) using Java Spring code only. AFAIK there is a special class RabbitAdmin for such configuration issues, but can't find out exactly how to set up the queues mirroring using it. Is it possible to configure HA queues in Java Spring somehow?
Thanx in advance.
Since RabbitMQ 3.0, you can no longer set mirroring using queue arguments:
Breaking things with RabbitMQ 3.0 .
You now have to use a policy on the broker.
Mirror queue policies
What changed? In RabbitMQ 3.0, queue mirroring is no longer controlled by the x-ha-policy
argument when declaring a queue. Your applications can continue to declare this argument, but it won't cause queues to be mirrored. Instead you can declare one or more policies which control which queues are mirrored, and how.
Why did it change? As anyone who's used mirrored queues will tell you, requiring applications to know which queues are mirrored is a pain. The new approach puts configuration in the broker, where it belongs, and also supports changing mirroring policy at any time.
What should I do? You need to make sure your queues are still mirrored. For the full documentation see here, but if you just want to make sure that all queues (except those with auto-generated names) are mirrored across all nodes, run:
rabbitmqctl set_policy HA '^(?!amq\.).*' '{"ha-mode": "all"}'
In earlier versions, you could configure it with the RabbitAdmin
.