Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

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.

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);
like image 578
Sumit Srivastava Avatar asked Oct 28 '25 05:10

Sumit Srivastava


2 Answers

You need to configure the splitter to use masterPoolProfile as the thread pool or configure the masterPoolProfile to be the default profile. The latter means all threads pools created using that API in Camel will use this profile as baseline.

Read more about this in the Camel docs: http://camel.apache.org/threading-model.html

like image 88
Claus Ibsen Avatar answered Oct 29 '25 21:10

Claus Ibsen


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)
like image 20
Abundance Avatar answered Oct 29 '25 19:10

Abundance



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!