-
Notifications
You must be signed in to change notification settings - Fork 41.5k
Description
When using spring integration JMS support and boot default configuration with ActiveMQ there is an error on startup:
...Cannot create inner bean '(inner bean)#5c49045d' of type [org.springframework.integration.jms.DynamicJmsTemplate] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#5c49045d': Cannot resolve reference to bean 'jmsConnectionFactory' while setting bean property 'connectionFactory'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'jmsConnectionFactory' available
It is related to
https://docs.spring.io/spring-integration/reference/html/jms.html#jms-inbound-channel-adapter
By default, all of the JMS adapters that require a reference to the ConnectionFactory automatically look for a bean named jmsConnectionFactory. That is why you do not see a connection-factory attribute in many of the examples. However, if your JMS ConnectionFactory has a different bean name, you need to provide that attribute.
It looks like it is caused that by default spring boot ActiveMQ auto configuration creates cachingJmsConnectionFactory
bean instead of jmsConnectionFactory
The issue can be resolved by configuration
spring.jms.cache.enabled=false
Or by alias
It looks like
https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/activemq/ActiveMQConnectionFactoryConfiguration.java#L75
should have additional names defined.
From outside it is hard to see it other auto configured beans (nonXaJmsConnectionFactory, pooledJmsConnectionFactory) should be also aliased to jmsConnectionFactory
Tested with
Spring Boot 2.1.2
Spring Integration 5.1.5
Attaching sample application.
spring-boot-activemq-integration.zip