【问题标题】:Spring integration flow with two sources具有两个来源的 Spring 集成流程
【发布时间】:2017-11-05 11:30:46
【问题描述】:

我尝试创建一个从 2 个源(1 个 mqtt 和一个来自用户服务交互)获取消息的流,并将消息生成到另一个 mqtt。 事实上,我尝试使用这个答案:How to crate Spring Integration Flow from two MessageProducerSpec?

这是我的结果:

@Bean
public IntegrationFlow mqttInFlow() {
    return IntegrationFlows.from(mqttInbound())
            .channel("mainMessageChannel")
            .get();
}

@Bean
public IntegrationFlow mqttTestMessageFlow() {
    return IntegrationFlows.from(messageService.testInbound())
            .channel("mainMessageChannel")
            .get();
}

@Bean
public IntegrationFlow mainMessageFlow() {
    return IntegrationFlows.from("mainMessageChannel")
            .handle(eventServiceHandler())
            .split(operationSplitter())
            .handle(mqttOutbound())
            .get();
}

但我有以下错误:

java.lang.IllegalStateException: 'outputChannel' or 'outputChannelName' is required
    at org.springframework.util.Assert.state(Assert.java:70)
    at org.springframework.integration.endpoint.MessageProducerSupport.afterSingletonsInstantiated(MessageProducerSupport.java:136)

【问题讨论】:

    标签: java spring spring-integration spring-annotations


    【解决方案1】:

    好吧,你必须在那些 MessageProducerSupport 定义中使用它,而不是像 channel("mainMessageChannel")

    @Bean
    MessageProducerSupport mqttInbound() {
       ...
       adapter.setOutputChannelName("mainMessageChannel");
       ...
    }
    
    @Bean
    MessageProducerSupport testInbound() {
       ...
       adapter.setOutputChannelName("mainMessageChannel");
       ...
    }
    

    或者...只是不要对它们进行@Bean 注释,Java DSL 会处理它们的声明!

    【讨论】:

      猜你喜欢
      • 2019-07-29
      • 2016-03-02
      • 2021-07-09
      • 2017-01-27
      • 1970-01-01
      • 1970-01-01
      • 2015-01-16
      • 2023-04-07
      • 1970-01-01
      相关资源
      最近更新 更多