Spring集成:分派器没有该频道的订阅者

时间:2019-05-16 16:46:39

标签: java spring spring-integration

我正在尝试构建一个具有以下配置的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),并且该异常不再发生。

1 个答案:

答案 0 :(得分:2)

xsltSpecific只是默认的DirectChannelUnicastingDispatcher,用于将消息传递给频道的订户。

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

<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",但另一方面,您可能确实在运行时停止了它。

您是否愿意就此事分享更多的堆栈跟踪信息?我想看看谁是丢失消息的原始呼叫者。

相关问题