Uploaded image for project: 'Red Hat Fuse'
  1. Red Hat Fuse
  2. ENTESB-12097

Unable to Manage Jetty Thread Pool with Rest DSL

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Major Major
    • None
    • fuse-6.x-GA
    • Camel
    • None
    • % %
    • Thread leak issue will be addressed in Fuse 7.6.0.GA.
    • Hide

      Reproducer attached. To test failure to manage thread pool size via endpointProperties, uncomment the lines:

                  <!--endpointProperty key="minThreads" value="20"/>
                  <endpointProperty key="maxThreads" value="20"/-->
      

      and comment the lines:

          <bean id="jetty" class="org.apache.camel.component.jetty9.JettyHttpComponent9">
              <property name="minThreads" value="20"/>
              <property name="maxThreads" value="20"/>
              <property name="enableJmx" value="true"/>
          </bean>
      

      deploy the bundle and check the jetty thread pool attributes in jconsole other JMX browser. Only the default pool is present, with default values.

      To check the pool leak, comment out the endpointProperty lines and uncomment the jetty bean. Build and deploy.

      Now, we see an extra jetty thread pool in JMX, with appropriate values corresponding to the values in the blueprint.

      Gather a thread dump of the container.

      Stop and start the camel-cxfrs-jetty-thread-pool bundle.

      Wait until the context starts and gather another thread dump.

      We see the jetty threads increasing by minThreads with each restart.

      Show
      Reproducer attached. To test failure to manage thread pool size via endpointProperties, uncomment the lines: <!--endpointProperty key= "minThreads" value= "20" /> <endpointProperty key= "maxThreads" value= "20" /--> and comment the lines: <bean id= "jetty" class= "org.apache.camel.component.jetty9.JettyHttpComponent9" > <property name= "minThreads" value= "20" /> <property name= "maxThreads" value= "20" /> <property name= "enableJmx" value= " true " /> </bean> deploy the bundle and check the jetty thread pool attributes in jconsole other JMX browser. Only the default pool is present, with default values. To check the pool leak, comment out the endpointProperty lines and uncomment the jetty bean. Build and deploy. Now, we see an extra jetty thread pool in JMX, with appropriate values corresponding to the values in the blueprint. Gather a thread dump of the container. Stop and start the camel-cxfrs-jetty-thread-pool bundle. Wait until the context starts and gather another thread dump. We see the jetty threads increasing by minThreads with each restart.

      It does not appear to be possible to effectively manage Jetty thread pool sizes when using REST DSL in Camel.

      Trying to set the thread pool minimum and maximum sizes via endpointProperty values as below appears to be ignored:

              <restConfiguration bindingMode="json" component="jetty" host="{{server.host}}" port="{{server.port}}" scheme="http">   
                  <endpointProperty key="servletName" value="RestServlet"/>
                  <endpointProperty key="minThreads" value="20"/>
                  <endpointProperty key="maxThreads" value="20"/>
                  <dataFormatProperty key="prettyPrint" value="true"/>
                  <dataFormatProperty key="json.in.disableFeatures" value="FAIL_ON_UNKNOWN_PROPERTIES,ADJUST_DATES_TO_CONTEXT_TIME_ZONE"/>
                  <dataFormatProperty key="json.in.enableFeatures" value="FAIL_ON_NUMBERS_FOR_ENUMS,USE_BIG_DECIMAL_FOR_FLOATS"/>
              </restConfiguration>
      

      Setting the values explicitly in a "jetty" bean seems to work a little better:

          <camelContext id="restTestJetty" trace="false" xmlns="http://camel.apache.org/schema/blueprint">  
             
              <restConfiguration bindingMode="json" component="jetty" host="{{server.host}}" port="{{server.port}}" scheme="http">   
                  <endpointProperty key="servletName" value="RestServlet"/>
                  <dataFormatProperty key="prettyPrint" value="true"/>
                  <dataFormatProperty key="json.in.disableFeatures" value="FAIL_ON_UNKNOWN_PROPERTIES,ADJUST_DATES_TO_CONTEXT_TIME_ZONE"/>
                  <dataFormatProperty key="json.in.enableFeatures" value="FAIL_ON_NUMBERS_FOR_ENUMS,USE_BIG_DECIMAL_FOR_FLOATS"/>
              </restConfiguration>
      
              <rest consumes="application/json" path="/OutputService" produces="application/json">
                  <get
                      outType="java.lang.String" uri="/{type}/{ip}">
                      <description>Lookup a location</description>
                      <to uri="bean:inputService?method=getLoc(${header.type}, ${header.ip})"/>
                  </get>
              </rest>
              
              <rest consumes="application/json" path="/InputService" produces="application/json">
                  <put
                      outType="java.lang.String" uri="/{type}/{ip}/{loc}">
                      <description>Store a location</description>
                      <to uri="bean:inputService?method=setLoc(${header.type}, ${header.ip}, ${header.loc})"/>
                  </put>
              </rest>
          </camelContext>
      

      however, restarting the component / bundle results in thread pool leakage and we can see the number of threads increasing by the thread pool minimum size with each restart.

              rhn-support-dhawkins Duane Hawkins
              rhn-support-dhawkins Duane Hawkins
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: