Comments (4)
Looks like RabbitTemplate is also added to the context and "rabbitTemplate" would be a default name for it.
I would suggest using unique bean names and the getBean(Class<T> requiredType)
method.
from spring-amqp.
When I getBean by AsyncRabbitTemplate type and keep the name "rabbitTemplate", the following exception is thrown:
java.util.concurrent.ExecutionException: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.amqp.rabbit.AsyncRabbitTemplate' available
My source code is
AsyncRabbitTemplate rabbitTemplate =
(AsyncRabbitTemplate) ApplicationContextUtil.getBean(AsyncRabbitTemplate.class);
But when I modify the bean name to "asyncRabbitTemplate", this exception is not thrown.
from spring-amqp.
I have found the reason. In spring boot, the RabbitAutoConfiguration is enabled by default. So a rabbitTemplate bean is created by default. Though I redefined a rabbitTemplate bean, it is still overrided by
the default RabbitTemplate bean.
But when I exclude RabbitAutoConfiguration in configuration, the above problems do not happen again.
from spring-amqp.
thank you for the assistance on the issue!
Your problem that by default, when several beans with the same name are configured, the last one wins.
In your case that is RabbitTemplate
@Bean
from the RabbitAutoConfiguration
.
Therefore your one is overridden.
Yes, only a solution to declare your own bean with unique name, but still get a gain from the RabbitAutoConfiguration
, e.g. rabbitConnectionFactory
bean and so on.
from spring-amqp.
Related Issues (20)
- WARN------Using deprecated '-debug' fallback for parameter name resolution. HOT 1
- Consumer won't reconnect to rabbitmq cluster probably / main thread won't die HOT 4
- Get rid of `synchronized (this.consumersMonitor)` in the `SimpleMessageListenerContainer`
- CachingConnectionFactory leaks channels during connection resets when used in a SimpleMessageContainer HOT 1
- RabbitTemplate with SIMPLE correlation causes uncached channels
- Get rid of `synchronized` blocks in the `CachingConnectionFactory`
- Get rid of `synchronized` in `RabbitAdmin`
- Get rid of `synchronized` in `RabbitTemplate` HOT 1
- Get rid of `synchronized` in the `BlockingQueueConsumer`
- Get rid of `synchronized` in `spring-rabbit-test` module
- Get rid of the rest of `synchronized` in the ListenerContainer infrastructure
- Improve Extensibility of RepublishMessageRecovererWithConfirms by supporting SpEL expressions HOT 1
- AmqpRejectAndDontRequeueException completely restarts Consumer HOT 2
- The `SimpleMessageListenerContainer` does not shutdown properly
- The `SimpleMessageListenerContainer` does not shutdown properly HOT 1
- Swallowed exception 'AmqpTimeoutException: No available channels' HOT 4
- Add batchReceiveTimeout in SimpleMessageListenerContainer HOT 3
- MessageProperties setDelay maximum value problem HOT 3
- ImmediateAcknowledgeAmqpException keeps the message in the queue HOT 10
- TraceId propagation to the new thread local HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spring-amqp.