-
Notifications
You must be signed in to change notification settings - Fork 40.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spring Boot 1.4 - RabbitMQ Cannot override primary ConnectionFactory and create secondary ConnectionFactory #6559
Comments
That doesn't sound legit to me. It looks like something is looking for a bean with that name and Spring Boot won't do that. Can you share a sample that reproduces the problem? |
Couldn't agree more but after removing all references to pcConnectionFactory the same error kept coming up. I've created a really basic sample that reproduces the problem. The zip file attachment here never works for me, so I've dropped the zip file with the sample here: |
@chrisdadej all the Spring Cloud stuff is really polluting the sample. I've taken your class, added it to a Spring Boot 1.4 project created from start.spring.io and it didn't throw any issue. I think the issue is a bit more complicated. I can't reproduce and I have no idea where that lookup on your named connection factory is coming from. But it doesn't seem to be in Spring Boot. Can you try to simplify your sample a bit? Maybe the issue is in another project. |
It looks like an incompatibility between Spring Boot 1.4 and Spring Cloud Brixton.
for:
works as expected. I'm assuming you were able to replicate the issue as is with my sample? You just weren't able to replicate it after taking out the Spring Cloud components. I can post this to the Spring Cloud team for them to have a look at but there's definitely been a change made in 1.4 that isn't backwards compatible. |
@chrisdadej the cross post is far from ideal. I am closing this one for now, let's see what the spring cloud team says. |
I ran into the same issue as Chrisdadej. I have an application with multiple Rabbit ConnectionFactory beans and it resulted in a NoSuchBeanDefinitionException. I think the problem is with spring-boot-autoconfigure project and not with spring-cloud. I was able to debug the problem to OnBeanCondition class in spring-boot-autoconfigure project. First of all, ConditionalOnSingleCandidate(ConnectionFactory.class) (¹) annotation was added to rabbitTemplate bean definition in org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration$RabbitTemplateConfiguration class as part of commit 9c73312.
When there are multiple connection factories, evaluation of ConditionalOnSingleCandidate fails to find any beans of type ConnectionFactory. org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchingBeans(ConditionContext, BeanSearchSpec) (²) method checks for matching bean definitions of type ConnectionFactory in the supplied beanFactory and the parent beanFactory references. However OnBeanCondition.hasSingleAutowireCandidate(ConfigurableListableBeanFactory beanFactory, List beanNames) (³) method does not recursively check in the parent beanFactory references. That results in a NoSuchBeanDefinitionException.
This issue is preventing me from upgrading to 1.4.0.RELEASE of spring-boot. @chrisdadej @snicoll could this issue be reopened? |
@buwi can you share a sample that reproduces the problem please? |
Since upgrading to Spring Boot 1.4 I've noticed that all of my microservices that override the primary ConnectionFactory AND create a secondary ConnectionFactory stopped working due to a
NoSuchBeanDefinitionException
.This works - not overriding the primary ConnectionFactory, just creating a secondary one
This works - overriding the primary ConnectionFactory without a secondary one
This fails - overriding the primary ConnectionFactory AND creating a secondary one
Stack Trace:
The text was updated successfully, but these errors were encountered: