2

I would like to create rabbitmq queues everytime my Spring Boot application starts (if queues don't exists already).

In the current architecture, we manually create durabl queues using rabbitmq admin. But we want our application, to detect new queues in the configuration and create durable ones if they don't exist

user7475347
  • 21
  • 1
  • 2
  • Possible duplicate of [How to get Spring RabbitMQ to create a new Queue?](https://stackoverflow.com/questions/16370911/how-to-get-spring-rabbitmq-to-create-a-new-queue) – Rafael Renan Pacheco Jul 03 '19 at 17:28

1 Answers1

2

That is built-in feature of Spring AMQP:

The AMQP specification describes how the protocol can be used to configure Queues, Exchanges and Bindings on the broker. These operations which are portable from the 0.8 specification and higher are present in the AmqpAdmin interface in the org.springframework.amqp.core package.

Since amqpAdmin bean is auto-configured by Spring Boot, you only need to declare particular @Beans for Queues, Exchanges and Bindings between them.

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118
  • need an example, since mine doesnt create – Kalpesh Soni Nov 08 '19 at 18:13
  • 1
    Here is one: https://github.com/spring-projects/spring-boot/tree/master/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-amqp – Artem Bilan Nov 08 '19 at 18:15
  • somewhere I read you have to create RabbitAdmin bean explicitely? I dont create it and right now my queues are not created automatically – Kalpesh Soni Nov 08 '19 at 18:19
  • 1
    Please, pay attention that this question is about Spring Boot, which auto-configure a `RabbitAdmin` for you. Otherwise, please, follow the mentioned docs and explicitly declare bean for it. Anyway this turns out to its own SO thread... – Artem Bilan Nov 08 '19 at 18:21
  • I use spring boot and cloud foundry - I ll add a new question – Kalpesh Soni Nov 08 '19 at 18:21
  • 1
    I think you also use Cloud Connectors which seems for me disable Spring AMQP auto-configuration. Therefore a `RabbitAdmin` should be created explicitly. – Artem Bilan Nov 08 '19 at 18:29