![](/img/trans.png)
[英]Spring Integration Junit Bridge a direct channel to testChannel
[英]spring integration bridge direct channel to queue Channel
在單元測試時,由於我要檢查流入該通道的消息量的正確性,因此嘗試將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。
我做錯了什么嗎?
您錯過了與我們分享測試案例的機會。 我們沒有整個圖片。 看起來您那里有比賽條件。 在開始斷言getqueuesize()
之前,有人輪詢了來自checkMyChannel
所有消息。
在我們的測試中,在這種情況下我們不使用<poller>
。 我們手動使用PollableChannel.receive(timeout)
。
解決此問題后,我必須將myChannel聲明為publish-subscribe-channel
如何測試Spring集成這對我的情況很有幫助,此后出現了競爭情況。 “具有多個訂閱者的常規頻道將循環播放...”
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.