Spring 集成 - Dispatcher 没有频道订阅者

Spring Integration - Dispatcher has no subscribers for channel

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

`

    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)(例如)可以解决问题,但显然是一种奇怪的解决方法。

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