簡體   English   中英

春季集成中如何使用路由器?

[英]how to use router in spring integration?

我在Spring Integration項目中使用router ,我想基於自定義表達式路由消息,因此,我定義了一個路由器和兩個路由消息通道,我的路由器代碼為:

<int:router input-channel="toSplitter"
                default-output-channel="aggregateResultsChannel"
                expression="@util.determine(payload)"
            >
        <int:mapping value="true" channel="mvChannel" />
        <int:mapping value="false" channel="toGet" />
    </int:router>

在我的豆子里:

public class util {
    public static boolean determine(List<FileInfo> path) {
        for(FileInfo fileInfo:path) {
             evaluate(fileInfo);
         }
         return;//how to return here...
    }  
}

問題是我想評估每個路徑對象並將每個消息路由到不同的通道,例如, list包含{file1,file2} ,然后在評估將file1路由到mvChannel和將file2路由到Get chennel后,該怎么做?

即使沒有任何<mapping>也可以配置<router> <mapping> 在這種情況下, route function必須返回MessageChannel bean名稱。

例如:


public class util {
    public static String determine(List<FileInfo> path) {
        return evaluate(path) ? "mvChannel" : "toGet";
    }  
}

暫無
暫無

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

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