简体   繁体   English

使用Spring Boot创建RabbitMQ队列

[英]Create RabbitMQ queues with spring boot

I would like to create rabbitmq queues everytime my Spring Boot application starts (if queues don't exists already). 我想在每次我的Spring Boot应用程序启动时创建Rabbitmq队列(如果队列尚不存在)。

In the current architecture, we manually create durabl queues using rabbitmq admin. 在当前体系结构中,我们使用Rabbitmq admin手动创建durabl队列。 But we want our application, to detect new queues in the configuration and create durable ones if they don't exist 但是我们希望我们的应用程序能够检测配置中的新队列,并在不存在持久队列的情况下创建持久队列

That is built-in feature of Spring AMQP : 这是Spring AMQP的内置功能:

The AMQP specification describes how the protocol can be used to configure Queues, Exchanges and Bindings on the broker. AMQP规范描述了如何使用协议在代理上配置队列,交换和绑定。 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. 从0.8规范开始可移植的这些操作在org.springframework.amqp.core软件包的AmqpAdmin界面中。

Since amqpAdmin bean is auto-configured by Spring Boot, you only need to declare particular @Bean s for Queue s, Exchange s and Binding s between them. 由于amqpAdmin bean是由Spring Boot自动配置的,因此您只需要为它们之间的QueueExchangeBinding声明特定的@Bean

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM