Repository: activemq-artemis Updated Branches: refs/heads/master 5678d1ad2 -> 914d93f63
ARTEMIS-482 Assign dedicated ThreadPool for InVMTransport Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/fc8a1eff Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/fc8a1eff Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/fc8a1eff Branch: refs/heads/master Commit: fc8a1eff43525a51fef4bc53a23df9f6f9cdaeae Parents: 5678d1a Author: Martyn Taylor <[email protected]> Authored: Thu Apr 14 12:46:57 2016 +0100 Committer: Martyn Taylor <[email protected]> Committed: Thu Apr 14 15:49:07 2016 +0100 ---------------------------------------------------------------------- .../core/remoting/impl/invm/InVMConnector.java | 24 ++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/fc8a1eff/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnector.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnector.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnector.java index c1fab77..0783d7c 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnector.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMConnector.java @@ -22,11 +22,17 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.Executor; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.SynchronousQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; import org.apache.activemq.artemis.api.core.ActiveMQException; +import org.apache.activemq.artemis.api.core.client.ActiveMQClient; import org.apache.activemq.artemis.core.server.ActiveMQComponent; -import org.apache.activemq.artemis.core.server.ActiveMQServerLogger; import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle; +import org.apache.activemq.artemis.core.server.ActiveMQServerLogger; import org.apache.activemq.artemis.spi.core.remoting.AbstractConnector; import org.apache.activemq.artemis.spi.core.remoting.Acceptor; import org.apache.activemq.artemis.spi.core.remoting.BaseConnectionLifeCycleListener; @@ -86,6 +92,20 @@ public class InVMConnector extends AbstractConnector { private final Executor closeExecutor; + private static ExecutorService threadPoolExecutor; + + private static ExecutorService getInVMExecutor() { + if (threadPoolExecutor == null) { + if (ActiveMQClient.globalThreadMaxPoolSize <= -1) { + threadPoolExecutor = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), Executors.defaultThreadFactory()); + } + else { + threadPoolExecutor = Executors.newFixedThreadPool(ActiveMQClient.globalThreadMaxPoolSize); + } + } + return threadPoolExecutor; + } + public InVMConnector(final Map<String, Object> configuration, final BufferHandler handler, final ClientConnectionLifeCycleListener listener, @@ -101,7 +121,7 @@ public class InVMConnector extends AbstractConnector { this.closeExecutor = closeExecutor; - executorFactory = new OrderedExecutorFactory(threadPool); + executorFactory = new OrderedExecutorFactory(getInVMExecutor()); InVMRegistry registry = InVMRegistry.instance;
