Disable RabbitTemplate bean creation via configuration

See original GitHub issue

Related to #3587 and possibly to spring.rabbitmq.dynamic=false.

I’d like to run tests that must not use the local RabbitMQ server. The autoconfiguration creates a RabbitTemplate bean which automatically connects to my local RabbitMQ server and, when used, sends messages into the system.

I tried setting spring.rabbitmq.listener.auto-startup=false (see #3587), but this does not help. Setting spring.rabbitmq.host= does not seem to do anything, and any (other) invalid option causes a timeout.

A workaround is to create a (mock) bean of type RabbitTemplate. However, this would be my only explicit reference to RabbitMQ from my code, as I’m using AMQP interfaces everywhere.

Could you please add an option to disable RabbitMQ/RabbitTemplate via configuration?

I can already disable AmqpTemplate autocreation using spring.rabbitmq.dynamic=false. Similarly (with better names imho), I can already disable Eureka (eureka.client.enabled=false) and Spring Cloud Bus (spring.cloud.bus.enabled=false).

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

17reactions
wilkinsonacommented, Aug 25, 2016

Could you please add an option to disable RabbitMQ/RabbitTemplate via configuration?

We already have such an option. You can disable any auto-configuration class using the spring.autoconfigure.exclude property. In this case it would be:

spring.autoconfigure.exclude: org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration

Does that meet your needs?

3reactions
C-Ottocommented, Aug 25, 2016

Thank you very much! Yes, it helps - also with other issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - Disabling the listening to rabbit queues from spring ...
I did find a way not to load the amqp-context.xml beans that contain the listener definitions by using Spring profiles and add <beans...
Read more >
Spring AMQP
Starting with version 2.0.2, the RabbitTemplate has a configuration option to automatically use a second connection factory, unless transactions are being used.
Read more >
The BeanDefinitionOverrideException in Spring Boot - Baeldung
Let's create two different Spring configurations, each with a testBean() method, to produce the BeanDefinitionOverrideException:.
Read more >
Messaging with RabbitMQ in Spring Boot Application
In our example, we are disabling the default behavior of RabbitMQ by disabling RabbitAutoConfiguration class. We need a custom Configuration ...
Read more >
Integrate Spring Boot with RabbitMQ easily | by Júlio Falbo
We would at least need to create a couple of beans like ... You can disable the autoconfiguration, using the properties below:
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found