2016-11-29 121 views
1

我使用apache camel-cdi和wildfly 8.2。如何爲駱駝配置線程池? 在文檔中,我只看到配置春天,但我用java ee與wildfly阿帕奇駱駝配置

回答

1

您可以檢查Java DSL配置爲create a thread pool in Camel

import org.apache.camel.spi.ExecutorServiceManager; 
import org.apache.camel.spi.ThreadPoolProfile; 
ExecutorServiceManager manager = context.getExecutorServiceManager(); 
ThreadPoolProfile defaultProfile = manager.getDefaultThreadPoolProfile(); 
// Now, customize the profile settings. 
defaultProfile.setPoolSize(SomeSize); 
defaultProfile.setMaxQueueSize(QueueSize); 
0

這取決於你的用例,但你肯定可以使用線程池與駱駝Java DSL。格式如下:

ExecutorService threadPool = Executors.newFixedThreadPool(20); 

.split(body().tokenize("\n")).streaming().executorService(threadPool) 

單個組件也可以允許單獨的線程(例如參見file2)。如果你有駱駝在行動書,第10章是關於併發性。它更詳細地介紹了線程和併發。

+0

在那裏我可以駱駝configurate池的大小? – mystdeim

+0

它在上面的代碼片段中,20個在Executors.newFixedThreadPool(20);是線程的數量。 – David

+0

你瘋了嗎,我有數百條漫長的路線。我需要配置默認池 – mystdeim