首页 > 解决方案 > Spring 集成:Dispatcher 没有频道订阅者

问题描述

我正在尝试构建一个 spring 集成应用程序,它具有以下配置(罪魁祸首似乎是通道xsltSpecific):

<beans:beans>   
    <channel id="channel1"></channel>
    <channel id="channel2"></channel>
    <channel id="xsltSpecific"></channel>
    <channel id="xsltSpecificDelayed"></channel>
    <channel id="xsltCommon"></channel>
    <channel id="irdSpecificUnmarshallerChannel"></channel>
    <channel id="irdSpecificInputChannel"></channel>

    <file:outbound-channel-adapter
        directory="${dml.ird.directory}" channel="channel1"
        auto-create-directory="true" filename-generator="timestampedFileNameGenerator">
    </file:outbound-channel-adapter>

    <recipient-list-router input-channel="fileChannel">
        <recipient channel="channel1" selector-expression="${dml.data.logs.enable}" />
        <recipient channel="channel2" />
    </recipient-list-router>
    <recipient-list-router input-channel="channel2">
        <recipient channel="xsltSpecificDelayed"></recipient>
        <recipient channel="xsltCommon"></recipient>
    </recipient-list-router>

    <delayer id="specificDelayer" input-channel="xsltSpecificDelayed" default-delay="5000" output-channel="xsltSpecific"/>

    <jms:message-driven-channel-adapter
        id="jmsInboundAdapterIrd" destination="jmsInputQueue" channel="fileChannel"
        acknowledge="transacted" transaction-manager="transactionManager"
        error-channel="errorChannel" client-id="${ibm.jms.connection.factory.client.id}"
        subscription-durable="true" durable-subscription-name="${ibm.jms.subscription.id1}" />

    <si-xml:xslt-transformer input-channel="xsltCommon" output-channel="jmsInputChannel"
        xsl-resource="classpath:summit-hub-to-cpm-mapping.xsl" result-transformer="resultTransformer" >
    </si-xml:xslt-transformer>

    <si-xml:xslt-transformer input-channel="xsltSpecific" output-channel="irdSpecificUnmarshallerChannel"
        xsl-resource="classpath:summit-hub-specific.xsl" result-transformer="resultTransformer" >
    </si-xml:xslt-transformer>

    <si-xml:unmarshalling-transformer id="irdUnmarshaller"
        unmarshaller="irdUnmarshallerDelegate" input-channel="irdSpecificUnmarshallerChannel"
        output-channel="saveSpecificTradeChannel" />

    <beans:bean id="irdUnmarshallerDelegate"
        class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
        <beans:property name="schema"
            value="summit-hub-specific.xsd" />
        <beans:property name="contextPath"
            value="com.h.i.c.d.i.mapping" />
    </beans:bean>

    <beans:bean id="resultTransformer" class="org.springframework.integration.xml.transformer.ResultToStringTransformer" />

    <service-activator ref="specificTradeService" input-channel="saveSpecificTradeChannel" 
        requires-reply="false" method="save"/>

    <file:inbound-channel-adapter directory="${dml.retry.directoryForIrd}"
        channel="fileChannelAfterRetry" auto-create-directory="true"
        prevent-duplicates="false" filename-regex=".*\.(msg|xml)" queue-size="50" >
        <poller fixed-delay="${dml.retry.delay}" max-messages-per-poll="50">
            <transactional transaction-manager="transactionManager" />
        </poller>
    </file:inbound-channel-adapter>

    <channel id="fileChannel"/>
    <channel id="fileChannelAfterRetry"/>

    <file:file-to-string-transformer
        input-channel="fileChannelAfterRetry" output-channel="fileChannel"
        delete-files="true" />

    <beans:import resource="classpath:cpm-dml-common-main.xml" />
</beans:beans>

但我有以下例外:

org.springframework.messaging.MessageDeliveryException: Dispatcher has no subscribers for channel 'org.springframework.context.support.GenericApplicationContext@6950e31.xsltSpecific'.; nested exception is org.springframework.integration.MessageDispatchingException: Dispatcher has no subscribers

这个例外是什么意思?另外,我无法发现问题,您能帮我解决这个问题吗?

更新

抱歉,我之前没有给出整个上下文,因为我认为它不相关。在从 派生的测试期间出现异常,该测试在测试AbstractTransactionalJUnit4SpringContextTests结束时关闭应用程序上下文,在消息有机会到达结束之前。我Thread.sleep(10000)在测试结束时添加了一个,异常不再发生。

标签: javaspringspring-integration

解决方案


xsltSpecific只是将消息传递给频道订阅者的默认DirectChannel设置。UnicastingDispatcher

根据您的配置,您从以下渠道向该频道发送消息:

<delayer id="specificDelayer" input-channel="xsltSpecificDelayed" default-delay="5000" output-channel="xsltSpecific"/>

而且看起来你真的有这个频道的订阅者:

<si-xml:xslt-transformer input-channel="xsltSpecific" output-channel="irdSpecificUnmarshallerChannel"
    xsl-resource="classpath:summit-hub-specific.xsl" result-transformer="resultTransformer" >
</si-xml:xslt-transformer>

当这个定义的订阅者丢失时,真正不清楚的是什么。看起来你auto-startup="false"在这个端点上没有一个,但另一方面,也许你真的在运行时停止它......

你介意分享更多关于这个问题的堆栈跟踪吗?我想看看谁是丢失消息的原始呼叫者。


推荐阅读