簡體   English   中英

聚合來自異步發布訂閱通道的響應

[英]Aggregating response from asynchronous publish subscribe channel

我需要異步調用4個Web服務並將結果聚合到單個消息中。如果其中一個服務需要更多時間來響應而不是指定的超時(3秒),則應該聚合已到達的剩余響應,並且應該延遲發送的消息被丟棄 為此,我在spring配置文件中使用了以下代碼段

<int:aggregator input-channel="aggregatorInputChannel" group-timeout="3000"  send-partial-result-on-expiry="true" expire-groups-upon-completion="true"  output-channel="aggregatorOutputChannel"  ref="responseAggregator"   method="populateResponseHeader" >
</int:aggregator> 

當其中一個Web服務(比如說service4)調用花費的時間超過超時值時,service4的線程將繼續在后台運行,服務器發送202響應。 關於我應該如何修改聚合器以忽略超時超時的消息並獲得響應的任何建議?

首先,你應該看一下Scatter-Gather模式。 看起來它足以滿足您的使用需求。

你應該使用expire-groups-upon-timeout="false"

<xsd:attribute name="expire-groups-upon-timeout">
                <xsd:annotation>
                    <xsd:documentation>
                        Boolean flag specifying, if a group is completed due to timeout (reaper or
                        'group-timeout(-expression)'), whether the group should be removed.
                        When true, late arriving messages will form a new group. When false, they
                        will be discarded. Default is 'true' for an aggregator and 'false' for a
                        resequencer.
                    </xsd:documentation>
                </xsd:annotation>
                <xsd:simpleType>
                    <xsd:union memberTypes="xsd:boolean xsd:string" />
                </xsd:simpleType>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM