activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject activemq git commit: https://issues.apache.org/jira/browse/AMQ-6126
Date Thu, 14 Jan 2016 15:42:33 GMT
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 <tabish121@gmail.com>
Authored: Thu Jan 14 10:41:56 2016 -0500
Committer: Timothy Bish <tabish121@gmail.com>
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<Runnable>(), new ThreadFactory() {
+        ThreadPoolExecutor rc = new ThreadPoolExecutor(getDefaultCorePoolSize(), getMaxThreadPoolSize(),
getDefaultKeepAliveTime(), TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), 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);
     }


Mime
View raw message