2015-02-05 120 views
0

我試圖路由基於三個不同的標準的對象。駱駝路由與自定義方法

我的問題是:

1)爲什麼我有沒有即路由對象轉到過濾器中的一個隨機的方式,而不是線性的?

2)如果這不起作用(示例),我應該怎麼做,如果我用「選擇」和「何時」來做,我可以使用自定義方法來路由嗎?就像這個例子使用過濾器

非常感謝

示例所示IM:

camelContext.addRoutes(new RouteBuilder() { 
@Override 
public void configure() throws Exception {         

    from("activemq:cfes.queue").filter().method(CustomCamelFilter.class, "methodOne") 
     .to("file://c:/u01/tomcat_conf/folder1");    

    from("activemq:cfes.queue").filter().method(CustomCamelFilter.class, "methodTwo") 
     .to("file://c:/u01/tomcat_conf/folder2"); 

    from("activemq:cfes.queue").filter().method(CustomCamelFilter.class, "methodThree") 
     .to("file://c:/u01/tomcat_conf/folder3"); 

回答

0

這是不正確的在這裏使用的.filter()模式,當它看來你確實應該使用.choice()模式相反,像這樣:

.choice() 
    .when(method(MyBean.class, "methodOne")).log("HELLO1") 
    .when(method(MyBean.class, "methodTwo")).log("HELLO2") 
    .when(method(MyBean.class, "methodThree")).log("HELLO3") 
    .otherwise().log("OOPS!") 
.end() 
+0

正是我所需要的。謝謝 – rogerbax 2015-02-05 13:40:56

+0

不用擔心,不客氣。 – vikingsteve 2015-02-05 13:44:40