【问题标题】:spring integration bridge direct channel to queue Channelspring 集成桥直接通道到队列通道
【发布时间】:2016-09-19 20:54:24
【问题描述】:

在单元测试时,我尝试将 Spring Integration 默认通道桥接到排队通道,因为我想检查进入此通道的消息流量的正确性。

<int:filter input-channel="prevChannel" output-channel="myChannel">
<int:bridge input-channel="myChannel" output-channel="aggregateChannel">
// the reason I have above bridge is I want to check the amount of message after filter.
// I cannot check prevChannel since it is before filtering, and I cannot check aggregateChannel 
// because it has other processing branch

// in test xml I import above normal workflow xml and added below configuration to 
// redirect message from myChannel to checkMyChannel to checking.


<int:bridge input-channel="myChannel"
            output-channel="checkMyChannel"/>

<int:channel id="checkMyChannel">    
    <int:queue/> 
</int:channel>

我在单元测试中自动装配了 checkMyChannel 但 checkMyChannel.getqueuesize() 总是返回 0。

是不是我做错了什么?

【问题讨论】:

    标签: spring spring-integration bridge


    【解决方案1】:

    您错过了与我们分享测试用例的机会。我们没有全貌。看起来你在那里有比赛条件。在您开始断言 getqueuesize() 之前,有人会从 checkMyChannel 轮询您的所有消息。

    在我们的测试中,我们不会在这种情况下使用&lt;poller&gt;。我们手动使用PollableChannel.receive(timeout)

    【讨论】:

    • 你的代码不起作用,因为我不知道gateway.publish()是什么,你也没有解释为什么需要&lt;int:poller&gt;
    • 哇!还有aggregateChannel。因此,您有两个 &lt;bridge&gt; 对应同一个 myChannel,它看起来像带有默认循环平衡器的 DirectChannel。所以,现在你的配置更复杂了。不确定您在这里寻求哪些帮助,但很难帮助不合作的人......
    【解决方案2】:

    解决了这个问题,我必须将 myChannel 声明为发布订阅频道

    How to test Spring Integration 这有帮助,就我而言,从那以后就有了竞争条件。 "一个有多个订阅者的常规频道将循环......"

    【讨论】:

      猜你喜欢
      • 2018-01-04
      • 2015-06-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-09
      • 2012-10-29
      • 1970-01-01
      • 2017-08-08
      相关资源
      最近更新 更多