Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 119CC18E93 for ; Thu, 14 Jan 2016 15:42:34 +0000 (UTC) Received: (qmail 98608 invoked by uid 500); 14 Jan 2016 15:42:33 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 98562 invoked by uid 500); 14 Jan 2016 15:42:33 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 98553 invoked by uid 99); 14 Jan 2016 15:42:33 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Jan 2016 15:42:33 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 6127CE3874; Thu, 14 Jan 2016 15:42:33 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tabish@apache.org To: commits@activemq.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: activemq git commit: https://issues.apache.org/jira/browse/AMQ-6126 Date: Thu, 14 Jan 2016 15:42:33 +0000 (UTC) Repository: activemq Updated Branches: refs/heads/master 928705533 -> ebcc1b4ea https://issues.apache.org/jira/browse/AMQ-6126 Add more configuration options to TaskRunnerFactory Project: http://git-wip-us.apache.org/repos/asf/activemq/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/ebcc1b4e Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/ebcc1b4e Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/ebcc1b4e Branch: refs/heads/master Commit: ebcc1b4eae194553e2e9764d9e0c337e0efc320f Parents: 9287055 Author: Timothy Bish Authored: Thu Jan 14 10:41:56 2016 -0500 Committer: Timothy Bish Committed: Thu Jan 14 10:41:56 2016 -0500 ---------------------------------------------------------------------- .../apache/activemq/thread/TaskRunnerFactory.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq/blob/ebcc1b4e/activemq-client/src/main/java/org/apache/activemq/thread/TaskRunnerFactory.java ---------------------------------------------------------------------- diff --git a/activemq-client/src/main/java/org/apache/activemq/thread/TaskRunnerFactory.java b/activemq-client/src/main/java/org/apache/activemq/thread/TaskRunnerFactory.java index ea1534f..2987997 100755 --- a/activemq-client/src/main/java/org/apache/activemq/thread/TaskRunnerFactory.java +++ b/activemq-client/src/main/java/org/apache/activemq/thread/TaskRunnerFactory.java @@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory; * Manages the thread pool for long running tasks. Long running tasks are not * always active but when they are active, they may need a few iterations of * processing for them to become idle. The manager ensures that each task is - * processes but that no one task overtakes the system. This is kinda like + * processes but that no one task overtakes the system. This is somewhat like * cooperative multitasking. * * @org.apache.xbean.XBean @@ -51,7 +51,7 @@ public class TaskRunnerFactory implements Executor { private boolean dedicatedTaskRunner; private long shutdownAwaitTermination = 30000; private final AtomicBoolean initDone = new AtomicBoolean(false); - private int maxThreadPoolSize = Integer.MAX_VALUE; + private int maxThreadPoolSize = getDefaultMaximumPoolSize(); private RejectedExecutionHandler rejectedTaskHandler = null; private ClassLoader threadClassLoader; @@ -166,7 +166,7 @@ public class TaskRunnerFactory implements Executor { } protected ExecutorService createDefaultExecutor() { - ThreadPoolExecutor rc = new ThreadPoolExecutor(0, getMaxThreadPoolSize(), getDefaultKeepAliveTime(), TimeUnit.SECONDS, new SynchronousQueue(), new ThreadFactory() { + ThreadPoolExecutor rc = new ThreadPoolExecutor(getDefaultCorePoolSize(), getMaxThreadPoolSize(), getDefaultKeepAliveTime(), TimeUnit.SECONDS, new SynchronousQueue(), new ThreadFactory() { @Override public Thread newThread(Runnable runnable) { String threadName = name + "-" + id.incrementAndGet(); @@ -182,14 +182,16 @@ public class TaskRunnerFactory implements Executor { LOG.error("Error in thread '{}'", t.getName(), e); } }); - + LOG.trace("Created thread[{}]: {}", threadName, thread); return thread; } }); + if (rejectedTaskHandler != null) { rc.setRejectedExecutionHandler(rejectedTaskHandler); } + return rc; } @@ -269,6 +271,14 @@ public class TaskRunnerFactory implements Executor { this.shutdownAwaitTermination = shutdownAwaitTermination; } + private static int getDefaultCorePoolSize() { + return Integer.getInteger("org.apache.activemq.thread.TaskRunnerFactory.corePoolSize", 0); + } + + private static int getDefaultMaximumPoolSize() { + return Integer.getInteger("org.apache.activemq.thread.TaskRunnerFactory.maximumPoolSize", Integer.MAX_VALUE); + } + private static int getDefaultKeepAliveTime() { return Integer.getInteger("org.apache.activemq.thread.TaskRunnerFactory.keepAliveTime", 30); }