【问题标题】:Spring Integration Java DSL - IntegrationFlow multiple subscribersSpring Integration Java DSL - IntegrationFlow 多个订阅者
【发布时间】:2016-11-09 02:20:55
【问题描述】:

我使用 Spring Integration DSL 的速度太快了。我正在玩下面的例子。

 @Bean
    public IntegrationFlow flow() {
        return IntegrationFlows.from(INBOX)
                .transform(p -> "world")
                .get();
    }

我正在寻找从这一流程中订阅多个频道的能力。我找不到任何关于此的信息。

例如像下面这样,这个流订阅了不同的频道。

 @Bean
        public IntegrationFlow flow() {
            return IntegrationFlows.from(INBOX).flow(INBOX2)
                    .transform(p -> "world")
                    .get();
        }

【问题讨论】:

    标签: java spring spring-integration


    【解决方案1】:

    这是不可能的。没有任何Endpoint 有几个inputChannels。

    另一方面,我们不需要这么复杂,因为我们总是可以 bridge 从一个频道到另一个频道:

    @Bean
    @BridgeTo(INBOX)
    public MessageChannel INBOX2() {
        return new DirectChannel();
    }
    

    您也可以考虑使用一些router 来始终评估所需的输出通道。

    MessageChannel 在 Spring Integration 设计中本身就很复杂,弄乱端点逻辑听起来不太好。

    【讨论】:

      【解决方案2】:

      在本教程[Receive and send multiple JMS messages in one transaction with Spring Integration Java DSL],他们是这样描述的

      但是,Java DSL 尚不能使用此属性。其他 解决这个问题的方法是替换消息驱动 带有事务轮询器的通道适配器,但这也不是 在当前的 Java DSL 中是可能的。为了解决这个问题,我们更换了 出站适配器中的 jmsFactory 带有带有会话的 jmsTemplate 交易设置为真。结果:

      IntegrationFlows
        .from(subscribableChannel())
        .handle(Jms.outboundAdapter(jmsTemplate).destination(QUEUE2))
      .get();
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-06-22
        • 2017-05-05
        • 2021-01-31
        • 1970-01-01
        • 1970-01-01
        • 2020-09-09
        相关资源
        最近更新 更多