【发布时间】:2020-01-07 01:14:42
【问题描述】:
我这几天一直在尝试使用 XML 配置在 Spring Integration 中设置多个 ActiveMQ 连接。
我正在使用spring boot,SI在上下文中寻找一个名为jmsConnectionFactory的bean并使用它。但是,如果我必须从不同的 ActiveMQ 服务器发送/收听 jms 消息怎么办?
我现在拥有的是这样的:
<bean id="jmsConnectionFactory1"
class="org.springframework.jms.connection.CachingConnectionFactory">
<property name="targetConnectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://localhost:61616" />
</bean>
</property>
<property name="sessionCacheSize" value="10" />
<property name="cacheConsumers" value="false" />
</bean>
<bean id="jmsConnectionFactory2"
class="org.springframework.jms.connection.CachingConnectionFactory">
<property name="targetConnectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://192.168.1.59:61616" />
</bean>
</property>
<property name="sessionCacheSize" value="10" />
<property name="cacheConsumers" value="false" />
</bean>
...
<jms:message-driven-channel-adapter channel="jmsInChannel" destination-name="queue.demo" />
<int:channel id="jmsInChannel" />
...
尝试启动 spring boot 应用程序时出现此错误:
***************************
APPLICATION FAILED TO START
***************************
Description:
A component required a bean named 'jmsConnectionFactory' that could not be found.
The following candidates were found but could not be injected:
- Bean method 'jmsConnectionFactory' in 'ActiveMQXAConnectionFactoryConfiguration' not loaded because @ConditionalOnClass did not find required class 'javax.transaction.TransactionManager'
Action:
Consider revisiting the entries above or defining a bean named 'jmsConnectionFactory' in your configuration.
我遇到了这个解决方案,https://stackoverflow.com/a/43401330/3367392 这是一个 java 配置。我也调查了这个,但它使用的是骆驼https://stackoverflow.com/a/13288312/3367392
有没有办法使用 XML 配置为 Spring Integration 实现相同的功能?
【问题讨论】:
标签: spring-boot spring-integration activemq javabeans spring-jms