4 Replies Latest reply on Nov 28, 2007 7:47 AM by Abel Munoz Alcaraz

    Messaging Timeout thread pool limits configuration

    Abel Munoz Alcaraz Newbie

      Hi all,
      Do you know any way to configure 'Messaging Timeout' thread queue limits? (MaximumQueueSize, MaximumPoolSize)

      I`m trying to run a unittest but the AS throws a cascade of exceptions like this (the thread queue is full):

      18:37:15,609 ERROR [Log4jService$ThrowableListenerLoggingAdapter] Unhandled Throwable
      org.jboss.util.threadpool.ThreadPoolFullException: java.lang.RuntimeException: Pool is blocked
       at org.jboss.util.threadpool.BasicThreadPool.execute(BasicThreadPool.java:417)
       at org.jboss.util.threadpool.BasicThreadPool.runTaskWrapper(BasicThreadPool.java:192)
       at org.jboss.util.threadpool.BasicThreadPool.run(BasicThreadPool.java:212)
       at org.jboss.util.threadpool.BasicThreadPool.run(BasicThreadPool.java:206)
       at org.jboss.util.timeout.TimeoutFactory.doWork(TimeoutFactory.java:223)
       at org.jboss.util.timeout.TimeoutFactory.access$000(TimeoutFactory.java:41)
       at org.jboss.util.timeout.TimeoutFactory$1.run(TimeoutFactory.java:136)


      I have update MessagingTimeoutFactory.java with:
      private void createFactory()
      {
       BasicThreadPool threadPool = new BasicThreadPool("Messaging Timeout");
       threadPool.setMaximumQueueSize(Integer.MAX_VALUE);
       factory = new TimeoutFactory(threadPool);
      }


      and the exceptions disapear.

      This update has test purpouses only. In production environment it should be a configurable parameter in destinations-service.xml.

      Is this feature available?

      Thanks at all,

        • 1. Re: Messaging Timeout thread pool limits configuration
          Abel Munoz Alcaraz Newbie

          Sorry,
          I have forgotten the unit test:

          public class StressDeadLock {
           static final int MAX_MESSAGES = 4* 1000;
           static final int MAX_ROLLBACK_MESSAGES = 5;
           static final int DELAY_TIME = 60000;
           static final String HOST_NAME = "nostromo";
           static final String QUEUE_NAME = "/queue/QueueWithOwnRedeliveryDelay";
          
           @Test
           public void stressTest1() {
           InitialContext ctx = null;
           ConnectionFactory connectionFactory = null;
           Queue destination = null;
           Connection sdnConnection = null;
           Connection rcvConnection = null;
           Session sndSession = null;
           Session rcvSession = null;
           MessageProducer producer = null;
           MessageConsumer consumer = null;
          
           String body = "Message schedule test";
          
           try {
           Properties props = new Properties();
           props.put(Context.INITIAL_CONTEXT_FACTORY,
           "org.jnp.interfaces.NamingContextFactory");
           props.put(Context.PROVIDER_URL, HOST_NAME + ":1099");
           props.put("java.naming.factory.url.pkgs",
           "org.jboss.naming:org.jnp.interfaces");
           ctx = new InitialContext(props);
           connectionFactory = (ConnectionFactory) ctx
           .lookup("/ConnectionFactory");
           destination = (Queue) ctx.lookup(QUEUE_NAME);
          
           sdnConnection = connectionFactory.createConnection();
           sndSession = sdnConnection.createSession(false,
           Session.AUTO_ACKNOWLEDGE);
          
           rcvConnection = connectionFactory.createConnection();
           rcvConnection.start();
           rcvSession = rcvConnection.createSession(true,
           Session.SESSION_TRANSACTED);
          
           consumer = rcvSession.createConsumer(destination);
           producer = sndSession.createProducer(destination);
          
           long deliveryTime = System.currentTimeMillis() + DELAY_TIME;
           int msgCounter = 0;
           int rollbackCounter = 0;
          
           while (msgCounter < MAX_MESSAGES) {
           TextMessage msg = sndSession.createTextMessage(body);
           msg.setLongProperty(
           JBossMessage.JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME,
           deliveryTime);
           producer.send(msg);
          
           msgCounter++;
           System.out.println("Sending " + msgCounter + "...");
           }
          
           while (consumer.receive(DELAY_TIME) != null) {
           if (rollbackCounter < MAX_ROLLBACK_MESSAGES) {
           rcvSession.rollback();
          
           rollbackCounter++;
           } else {
           rcvSession.commit();
           }
          
           msgCounter--;
           System.out.println("Pending for receive " + msgCounter + "...");
           }
          
           assertFalse(msgCounter > (-1 * rollbackCounter));
           } catch (Exception e) {
           fail(e.getMessage());
           } finally {
           if (consumer != null) {
           try {
           consumer.close();
           } catch (Exception e) {
           }
           }
          
           if (producer != null) {
           try {
           producer.close();
           } catch (Exception e) {
           }
           }
          
           if (sndSession != null) {
           try {
           sndSession.close();
           } catch (Exception e) {
           }
           }
           if (rcvSession != null) {
           try {
           rcvSession.close();
           } catch (Exception e) {
           }
           }
          
           if (rcvConnection != null) {
           try {
           rcvConnection.close();
           } catch (Exception e) {
           }
           }
          
           if (sdnConnection != null) {
           try {
           sdnConnection.close();
           } catch (Exception e) {
           }
           }
          
           if (ctx != null) {
           try {
           ctx.close();
           } catch (Exception e) {
           }
           }
           }
           }
          }
          


          • 2. Re: Messaging Timeout thread pool limits configuration
            Abel Munoz Alcaraz Newbie

            I have created a new feature request: JBMESSAGING-1163.

            • 3. Re: Messaging Timeout thread pool limits configuration
              Tim Fox Master

              I have put in a small change to make the queue unlimited for SP2.

              Not sure if we really need full configurability?

              • 4. Re: Messaging Timeout thread pool limits configuration
                Abel Munoz Alcaraz Newbie

                Hi Tim,
                in our production environment I have deployed an unbounded version of MessagingTimeoutFactory.

                I think it is a future feature in order to limit resource consumption in small computers or for testing purposes (I use it for this).