not helpful: multiple Rabbitmq queues with spring boot
Asked
Active
Viewed 438 times
2 Answers
1
@Gary Russell Thanks it worked well. another example.
public DirectExchange exchange(RabbitAdmin rabbitAdmin) {
DirectExchange directExchange = new DirectExchange("exchangeName", true, false);
rabbitAdmin.declareExchange(directExchange);
for (int num = 1; num <= 20; num++) {
Queue queue = new Queue("queueName" + num, true, false, false, null);
rabbitAdmin.declareQueue(queue);
rabbitAdmin.declareBinding(BindingBuilder.bind(queue).to(directExchange).with("routingKey" + num));
}
return directExchange;
}

dharmendra singh
- 51
- 3
0
Use RabbitAdmin.declareQueue()
in a loop.
List<Queue> queues = new ArrayList<>();
@Bean
public ApplicationRunner runner(RabbitAdmin admin) {
return args -> this.queues.forEach(queue -> admin.declareQueue(queue));
}

Gary Russell
- 166,535
- 14
- 146
- 179
-
2This would be a much better answer with an example. – Wonko the Sane Jan 16 '20 at 18:46
-
Seriously? Example addeed. – Gary Russell Jan 16 '20 at 18:49
-
Yes, and thank you. The pre-example version showed up in the Low Quality Posts queue. Rather than voting to close, I wrote the comment. This will help those with little experience. – Wonko the Sane Jan 16 '20 at 19:17