通过弹簧集成自动配置ActiveMQ

在当前版本中,
spring boot还可以在检测到ActiveMQ在类路径上可用时配置ConnectionFactory.如果存在代理,则会自动启动并配置嵌入式代理.

使用JMSTemplate时似乎也是如此.如果我想使用spring集成自动配置,那么不幸的是这不起作用. ActiveMQ似乎是在弹簧集成后配置的.缺少连接工厂的Spring引导报告错误.
我正在使用spring boot版本1.1.4和最新版本的spring集成.

我从spring boot获得了这个堆栈跟踪:

2014-08-08 09:24:21.050 ERROR 6728 --- [           main]    
o.s.boot.SpringApplication               : Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 
'org.springframework.integration.jms.JmsSendingMessageHandler#0': 
Cannot create inner bean '(inner bean)#54930080' 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)#54930080': Cannot resolve reference to 
bean 'connectionFactory' while setting bean property 'connectionFactory'; nested 
exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean 
named 'connectionFactory' is defined
at 
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(
BeanDefinitionValueResolver.java:290)
at   
org.springframework.beans.factory.support.BeanDefinitionValueResolver.
resolveValueIfNecessary(BeanDefinitionValueResolver.java:129)

对我来说,弹簧启动自动配置中的依赖关系似乎与spring集成和jms模板无关.
标准JMS自动配置如下所示:

@ConditionalOnClass(JmsTemplate.class)
@ConditionalOnBean(ConnectionFactory.class)
@EnableConfigurationProperties(JmsProperties.class)
@AutoConfigureAfter({ HornetQAutoConfiguration.class, 
ActiveMQAutoConfiguration.class })
public class JmsAutoConfiguration 

Spring集成如下所示:

@Configuration
@ConditionalOnClass(EnableIntegration.class)
@AutoConfigureAfter(JmxAutoConfiguration.class)
public class IntegrationAutoConfiguration {

对于连接工厂和活动mq弹簧集成创建的动态jms模板,不应该至少有某种自动配置.考虑到弹簧启动参考文档,我期望正确的自动配置与jms弹簧集成?

最佳答案 好的,我知道了.这是一个错误(我认为).

ActiveMQConnectionFactoryConfiguration创建了一个名为“jmsConnectionFactory”的bean,但查看了你的stacktrace(上图)Spring Integration正在寻找要命名的bean:’connectionFactory’

编辑:INT-3941开通

解决方法:

@Configuration
public static class SpringBootVsIntegraionWorkaround {
    @Autowired
    GenericApplicationContext genericApplicationContext;

    @PostConstruct
    public void init() {
        genericApplicationContext.registerAlias("jmsConnectionFactory", "connectionFactory");
    }
}
点赞