0 Replies Latest reply on May 31, 2013 5:45 PM by Hyrax Wang

    The unbounded buffer doesn't seem to work when setting consumer-window-size to -1

    Hyrax Wang Newbie

      Hi all,

      I'm using HornetQ 2.3.0 Final here.

      Since we have fast and slow consumers in our messaging system, I set consumer-window-size in hornetq-jms.xml to -1 hoping the client can have a local unbounded buffer so that no matter how slow it is, those unprocessed messages will remain on the client side not on the server side as paging files.

      To make sure I have set that variable correctly, I print out HornetQConnectionFactory.getConsumerWindowSize() when starting the client and it can be confirmed to be -1.

      Then I set up a fast producer sending one message every 300 ms, a normal consumer which is fast enough handling the messages mentioned before and a slow consumer which is simply added 30s delay when it handles an incoming message based on the normal consumer mentioned before.

      If I just start the producer and the normal consumer, no paging files will be observed but if I fire up the slow consumer, the paging files can be observed in a few seconds.

      My client side code is based the examples clustered-topic, for instance:

       

      import javax.jms.Connection;
      import javax.jms.ConnectionFactory;
      import javax.jms.MessageConsumer;
      import javax.jms.MessageProducer;
      import javax.jms.Session;
      import javax.jms.TextMessage;
      import javax.jms.Topic;
      import javax.naming.InitialContext;
      import org.hornetq.common.example.HornetQExample;
      
      public class ClusteredTopicExample extends HornetQExample
      {
         public static void main(final String[] args)
         {
            new ClusteredTopicExample().run(args);
         }
      
      
         @Override
         public boolean runExample() throws Exception
         {
            Connection connection0 = null;
      
            InitialContext ic0 = null;
      
      
            try
            {
               ic0 = getContext(0);
      
               Topic topic = (Topic)ic0.lookup("/topic/exampleTopic");
      
               HornetQConnectionFactory cf0 = (HornetQConnectionFactory)ic0.lookup("/ConnectionFactory");
      
               System.out.println("set consumer window size to " + cf0.getConsumerWindowSize()); // here we can confirm it is set to -1
      
               connection0 = cf0.createConnection();
      
               Session session0 = connection0.createSession(false, Session.AUTO_ACKNOWLEDGE);
      
               connection0.start();
      
               MessageProducer producer = session0.createProducer(topic);
      
              MessageConsumer consumer0 = session0.createConsumer(topic);
               ...
      

       

      In hornetq-jms.xml:

       

          ...
         <connection-factory name="ConnectionFactory">
            <connectors>
               <connector-ref connector-name="netty-connector"/>
            </connectors>
            <entries>
               <entry name="ConnectionFactory"/>
            </entries>
            <consumer-window-size>-1</consumer-window-size>
         </connection-factory>
         ...
      

       

      Could you please tell why this "unbounded buffer" does't work?

      Or do I misunderstand its meaning?

      Thanks a lot,

      Hyrax