2014-11-04 114 views
5

我正在Camel 2.10的RedHat Fuse Service Works中使用駱駝路由。駱駝並行處理選項

我想知道以下實施方式之間的差異:

1 /使用SEDA路由

from("A") 
    .split(body()) 
    .to("seda:B"); 

    from("seda:B?concurrentConsumers=4") 
    .routeId("MySEDATestRoute") 
    .to("C") 
    .end(); 

2 /採用並行處理

from("A") 
    .split(body()) 
    .parallelProcessing() 
    .to("C"); 

3 /使用線程

from("A") 
    .split(body()) 
    .threads() 
    .to("C"); 

從我看到的方法3(線程)允許配置線程池大小,它看起來與解決方案1(SEDA)的「concurrentConsumers」相同。

如果我沒有傳遞任何參數給方法線程,方法2和3的行爲是一樣的嗎?

由於提前,

問候

回答

1

您可以設置在1號線),3),但1)仍然能夠接收來自其他途徑的消息,從(XXX)。爲了就像( 「SEDA:B」)。 2)您需要設置ExecutorService(或ThreadPool),否則parallelProcessing將無法正常工作。

+1

所以幹嘛說的是,如果我知道我肯定不會有未來在其他的路線,我應該3)像.threads使用的解決方案( 2,10)? – user3416249 2014-11-05 09:38:55

0

下面是工作示例代碼:

CamelContext context = getContext(); 
ExecutorService service = new ThreadPoolBuilder(context).poolSize(10).maxPoolSize(150).maxQueueSize(150).build("CustomPool"); 

from("properties:{{file.fromLocation}}") 
    .log("Received the file...") 
    .split().tokenize("\n").executorService(service) 
    .streaming() 
    .parallelProcessing() 
+1

向下選民請提供一些意見! – sunleo 2017-11-20 05:40:09