我想将 JMS 添加到现有的 Spring 集成项目中。我要更改的 xml 文件如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
xmlns="http://www.springframework.org/schema/integration"
xmlns:jms="http://www.springframework.org/schema/integration/jms"
xmlns:int-http="http://www.springframework.org/schema/integration/http" xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/http http://www.springframework.org/schema/integration/http/spring-integration-http.xsd
http://www.springframework.org/schema/integration/jms http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd">
<channel id="eventUpdateChannel" />
<chain input-channel="eventUpdateChannel" output-channel="eventUpdateChannelRouter">
(...)
</chain>
(...)
</bean>
这工作正常,通过的消息eventUpdateChannel
被处理。
在查看 Spring Integration 站点的示例后,我将该 xml 文件更改为:
(...)
<channel id="eventUpdateChannel" />
<channel id="jmsEventUpdateChannel" />
<jms:message-driven-channel-adapter id="jmsIn" destination="inboundMessageQueue" channel="eventUpdateChannel" />
<jms:outbound-channel-adapter id="jmsOut" channel="jmsEventUpdateChannel" destination="inboundMessageQueue"/>
<chain input-channel="jmsEventUpdateChannel" output-channel="eventUpdateChannelRouter">
(...)
我还添加了这部分:
<!-- JMS -->
<bean id="connectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
<property name="targetConnectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="vm://localhost"/>
</bean>
</property>
<property name="sessionCacheSize" value="10"/>
<property name="cacheProducers" value="false"/>
</bean>
<bean id="inboundMessageQueue" class="org.apache.activemq.command.ActiveMQQueue">
<constructor-arg value="queue.request"/>
</bean>
现在,在应用程序启动后,当它收到一条消息时,消息未得到处理,我收到此警告:
org.springframework.integration.MessageDeliveryException: Dispatcher has no subscribers for channel eventUpdateChannel.