骆驼分割器为每个请求创建线程

时间:2018-08-02 06:55:31

标签: multithreading apache-camel

我们面临的问题是,骆驼拆分器正在为每个请求创建线程,而这些守护程序线程处于等待状态。以下是线程转储的代码段。

"Camel (camel-1) thread #1 - Split" #180 daemon prio=5 os_prio=0 tid=0x00007f2fdc01b800 nid=0x692a waiting on condition [0x00007f2f83abb000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000006c5f2dd98> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
    at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

在上述线程转储中,大约有4000个拆分线程处于等待状态,但是我们设置了最多800个线程的线程池。以下是相同的代码段。有人可以帮助我们解决问题。

CamelContext camelContext = super.camelContext();
            ExecutorServiceManager executorServiceManager = camelContext.getExecutorServiceManager();
            ThreadPoolProfile defaultThreadPoolProfile = executorServiceManager.getDefaultThreadPoolProfile();
            defaultThreadPoolProfile.setPoolSize(800);
            defaultThreadPoolProfile.setMaxPoolSize(800);
            defaultThreadPoolProfile.setDefaultProfile(true);

0 个答案:

没有答案