Diversified factories
I am using spring boot and setting up multiple connection factories (merged and jms). The problem I am getting is that it looks like it is trying to pass them to the same object in the javax.jms.ConnectionFactory. So this leads to this exception:
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.jms.ConnectionFactory org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration.connectionFactory; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [javax.jms.ConnectionFactory] is defined: expected single matching bean but found 2: jmsConnectionFactory,pooledConnectionFactory
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:561)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
... 38 more
Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [javax.jms.ConnectionFactory] is defined: expected single matching bean but found 2: jmsConnectionFactory,pooledConnectionFactory
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1054)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:942)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:533)
... 40 more
Here is the configuration I'm using:
<bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="***" />
</bean>
<bean id="pooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory" init-method="start" destroy-method="stop">
<property name="maxConnections" value="10" />
<property name="connectionFactory" ref="jmsConnectionFactory" />
</bean>
<bean id="jmsConfig"
class="org.apache.camel.component.jms.JmsConfiguration">
<property name="connectionFactory" ref="pooledConnectionFactory"/>
<property name="acknowledgementModeName" value="CLIENT_ACKNOWLEDGE"/>
<property name="concurrentConsumers" value="11"/>
<property name="maxConcurrentConsumers" value="11"/>
</bean>
<bean id="activemq"
class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="configuration" ref="jmsConfig"/>
</bean>
I guess the problem is that both of these classes are implementing the javax.jms.ConnectionFactory class and then they are automatically connected via ConnectionFactory in org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration. I am missing something here, any help would be greatly appreciated?
+3
source to share
1 answer