【问题标题】:dispatcher has no subscribers - spring integration JMS调度程序没有订阅者-spring集成JMS
【发布时间】:2013-08-16 13:19:09
【问题描述】:

我想将 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.

【问题讨论】:

    标签: java jms spring-integration


    【解决方案1】:

    您的适配器正在将其数据发送到不再订阅任何内容的eventUpdateChannel

    以前,&lt;chain/&gt; 已订阅它。

    根据您在下面的评论,您需要

    <channel id="eventUpdateChannel" />
    
    <jms:outbound-channel-adapter id="jmsOut" channel="eventUpdateChannel" destination="inboundMessageQueue"/>
    
    <jms:message-driven-channel-adapter id="jmsIn" destination="inboundMessageQueue"   channel="jmsEventUpdateChannel" />
    
    <channel id="jmsEventUpdateChannel" />
    
    <chain input-channel="jmsEventUpdateChannel" output-channel="eventUpdateChannelRouter">
    

    如果您所做的只是使用 JMS 进行持久化,您可以移除适配器并简单地将 eventUpdateChannel 设置为 jms 支持的通道。如果您使用它来将工作分配给其他 JVM,那么适配器是正确的选择。

    【讨论】:

    • 感谢您的反馈。现在不应该订阅jms:message-driven-channel-adapter 吗?如果不是像我这样做的那样,我应该如何将 jms 连接到该频道?
    • 否;消息驱动的适配器是生产者;没有消费者(订阅者)。我不知道你到底想做什么,所以我无法推测。您目前有 2 个订阅者 jmsEventUpdateChannel - 链和出站适配器。
    • 我希望来自 eventUpdateChannel 的消息进入 jms 队列并从该队列进入链。出站适配器是否应该连接到eventUpdateChannel,然后消息驱动适配器连接到jmsEventUpdateChannel
    • 效果很好,感谢您的帮助。我接受你的回答,我会给出 +1,但我没有足够的代表
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-11-02
    • 2013-09-25
    • 2017-04-10
    • 2018-02-19
    • 2020-04-22
    • 1970-01-01
    • 2016-12-31
    相关资源
    最近更新 更多