Uploaded image for project: 'ActiveMQ'
  1. ActiveMQ
  2. AMQ-6396

JVM property org.apache.activemq.transport.nio.SelectorManager.maximumPoolSize has no effect (post 5.14)

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 5.14.0
    • Fix Version/s: None
    • Component/s: Transport
    • Labels:
      None

      Description

      http://activemq.apache.org/nio-transport-reference.html should be improved and state that org.apache.activemq.transport.nio.SelectorManager.maximumPoolSize has no effect on the NIO transport pool size 5.14 and beyond.

      https://issues.apache.org/jira/browse/AMQ-6184 changed the work queue to an unbounded LinkedBlockingQueue, so the size of the thread pool never grows past the core pool size as per ThreadPoolExecutor's Javadoc:

      If there are more than corePoolSize but less than maximumPoolSize threads running, a new thread will be created only if the queue is full.

          protected ExecutorService createDefaultExecutor() {
              ThreadPoolExecutor rc = new ThreadPoolExecutor(getDefaultCorePoolSize(), getDefaultMaximumPoolSize(), getDefaultKeepAliveTime(), TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(),
                  new ThreadFactory() {
      
                      private long i = 0;
      
                      @Override
                      public Thread newThread(Runnable runnable) {
                          Thread t = new Thread(runnable, "ActiveMQ NIO Worker " + (i++));
                          t.setDaemon(true);
                          return t;
                      }
                  }, new ThreadPoolExecutor.CallerRunsPolicy());
      
              return rc;
          }
      

      Leaving the documentation as is can confuse users into thinking that the pool size should be capped using the maximumPoolSize property, although in reality it's the corePoolSize property that does that 5.14 and beyond.

      Personally this confused me greatly and wasted me a lot of time while stress-testing the MQTT NIO connector for my company. The broker would constantly hit a live lock and spawn only 10 threads for the NIO transport, even if I set the maximumPoolSize to a larger number.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              jason.j.baik@gmail.com Jason Baik
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: