[英]Parallel processing threads on split in Apache Camel
I am trying to split an incoming exchange in route based on some logic. 我试图根据一些逻辑拆分路由中的传入交换。 Every split part would connect to an ssh server in a bean. 每个拆分部分都将连接到bean中的ssh服务器。
from("seda:compression")
.routeId("Compressor")
.split(beanExpression(new InstanceListParser(), "process"))
.parallelProcessing()
.to("bean:compressorClient?method=compress(${header.remoteHost},${header.dataCenter})")
.end();
But it seems a maximum of 10 processes are being run in parallel. 但似乎最多有10个进程并行运行。
I added the following code to increase the size of thread pool factory, but this does not help. 我添加了以下代码来增加线程池工厂的大小,但这没有帮助。
ThreadPoolProfile poolProfile = new ThreadPoolProfile("masterPoolProfile");
poolProfile.setMaxPoolSize(100);
poolProfile.setMaxQueueSize(100);
poolProfile.setPoolSize(50);
poolProfile.setKeepAliveTime(1L);
poolProfile.setTimeUnit(TimeUnit.MINUTES);
ThreadPoolFactory poolFactory = new DefaultThreadPoolFactory();
poolFactory.newThreadPool(poolProfile, Executors.defaultThreadFactory());
getContext().getExecutorServiceManager().setThreadPoolFactory(poolFactory);
You need to configure the splitter to use masterPoolProfile
as the thread pool or configure the masterPoolProfile
to be the default profile. 您需要将拆分器配置为使用masterPoolProfile
作为线程池,或将masterPoolProfile
配置为默认配置文件。 The latter means all threads pools created using that API in Camel will use this profile as baseline. 后者意味着在Camel中使用该API创建的所有线程池都将使用此配置文件作为基线。
Read more about this in the Camel docs: http://camel.apache.org/threading-model.html 在Camel文档中了解更多相关信息: http : //camel.apache.org/threading-model.html
This works for me: 这对我有用:
ThreadPoolProfile poolProfile = new ThreadPoolProfile("masterPoolProfile");
poolProfile.setMaxPoolSize(100);
poolProfile.setMaxQueueSize(100);
poolProfile.setPoolSize(50);
poolProfile.setKeepAliveTime(1L);
poolProfile.setTimeUnit(TimeUnit.MINUTES);
getContext().getExecutorServiceManager().setDefaultThreadPoolProfile(poolProfile)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.