繁体   English   中英

在Apache Camel中拆分并行处理线程

[英]Parallel processing threads on split in Apache Camel

我试图根据一些逻辑拆分路由中的传入交换。 每个拆分部分都将连接到bean中的ssh服务器。

from("seda:compression")
    .routeId("Compressor")
    .split(beanExpression(new InstanceListParser(), "process"))
    .parallelProcessing()
        .to("bean:compressorClient?method=compress(${header.remoteHost},${header.dataCenter})")
    .end();

但似乎最多有10个进程并行运行。

我添加了以下代码来增加线程池工厂的大小,但这没有帮助。

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);

您需要将拆分器配置为使用masterPoolProfile作为线程池,或将masterPoolProfile配置为默认配置文件。 后者意味着在Camel中使用该API创建的所有线程池都将使用此配置文件作为基线。

在Camel文档中了解更多相关信息: http//camel.apache.org/threading-model.html

这对我有用:

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM