【问题标题】:Spring Integration - Dispatcher has no subscribers for channelSpring Integration - Dispatcher 没有频道订阅者
【发布时间】:2021-01-31 17:41:08
【问题描述】:

Spring Integration 5.3.2 的一个非常简单的示例:单个集成流,使用带有 IntegrationFlowContext 的 spring-integration DSL 注册:

`

    MessageChannel startChannel = MessageChannels.direct("channel").get();

    StandardIntegrationFlow flow = IntegrationFlows.from(startChannel)
            .log().get();

    flowContext.registration(flow)
            .autoStartup(false)
            .register();

    flow.start();

    startChannel.send(MessageBuilder.withPayload("test").build());`

产量org.springframework.messaging.MessageDeliveryException: Dispatcher has no subscribers for channel

为什么?添加单个.transform(e->e)(例如)可以解决问题,但显然是一种奇怪的解决方法。

【问题讨论】:

    标签: spring-integration


    【解决方案1】:

    这绝对是意料之中的行为。您声明了 MessageChannel 并向其中发送消息,但没有为该频道声明订阅者。因此,当您添加 transform() 时,您确实会看到不同之处。您应该自己决定您的逻辑是什么,以及当该频道中有消息时您想做什么。您可以考虑使用其他通道类型,但仍考虑以某种方式处理消息。

    【讨论】:

    • 谢谢。我并不总是清楚什么是订阅者,什么不是。
    • 参见log() JavaDocs:它是一个通道拦截器,而不是订阅者的端点
    • 谢谢。恐怕我还有更多问题,但我会在不同的 StackOverflow 线程中开始。
    猜你喜欢
    • 2017-05-05
    • 1970-01-01
    • 2019-10-04
    • 2018-09-17
    • 2020-09-09
    • 2019-10-12
    • 1970-01-01
    • 1970-01-01
    • 2022-08-19
    相关资源
    最近更新 更多