2016-09-19 69 views
0

在單元測試時間,我嘗試將Spring集成默認通道橋接到排隊通道,因爲我想檢查到此通道的消息流量的正確性。春季集成橋樑直接通道到隊列通道

<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.getqueuesize()自動裝配checkMyChannel始終返回0

有沒有......我做錯了什麼?

回答

0

得到這個固定的,我必須聲明myChannel是一個發佈 - 訂閱通道

How to test Spring Integration 此人幫助,我的情況有因爲競爭狀態。 「一個有多個用戶的常規頻道將循環...」

0

您錯過了與我們分享測試用例。我們沒有全部圖片。看起來你在那裏有一個競賽條件。在您開始斷言getqueuesize()之前,有人從checkMyChannel輪詢您的所有消息。

在我們的測試中,我們不使用<poller>這種情況。我們手動使用PollableChannel.receive(timeout)

+0

已編輯。請檢查,謝謝 – edi

+0

你的代碼不工作,因爲我不知道'gateway.publish()'是什麼,你沒有解釋你爲什麼需要'' –

+0

哇!還有'aggregateChannel'。所以,對於同一個'myChannel',你有兩個'',它看起來像帶有默認循環平衡器的'DirectChannel'。所以,現在你的配置更加複雜。不確定你在這裏尋找哪種幫助,但很難幫助不合作的人...... –