5 Replies Latest reply on Nov 24, 2009 1:14 PM by Poonam Agarwal

    Slow consumer is blocking producer

    Poonam Agarwal Newbie


      I am using Jboss 4.2.0 and JBoss Messaging 1.4.4.
      I am facing a performance issue.
      I am using 1 publisher and 1 subscriber to a Topic.
      I am trying to post 36000 messages to the topic from the producer.
      The subscriber(consumer) takes each message and does some processing.
      But, what I have observed is that the publisher is slow in posting messages on the topic. If I comment out the processing code on the consumer(MessageListener) , just print the received message, then I see the postToTopic becomes fast.

      I was of the view that Jboss Messaging is asynchronous. but, the above observation shows that a consumer is blocking producer which is like a synchronous call.
      I have tried to make Slow Consumer true and also increasing the pre-fetchsize but, nothing seems to make it faster. My framework performance is kinda disturbed bcoz of this behaviour.

      Can somebody help me to solve this problem please?


        • 1. Re: Slow consumer is blocking producer
          Yong Hao Gao Master

          What kind of subscriber you create? Can you try durable and non-durable and see if they make any difference? Thanks.


          • 2. Re: Slow consumer is blocking producer
            Tyronne Wickramarathne Newbie

            What's your client application? Is it a plain JMS client ? Can I take a look at your client code please?

            • 3. Re: Slow consumer is blocking producer
              Poonam Agarwal Newbie

              My subscriber is non-durable. Performance of non-durable should be better than a durable one. So, I don't think this will make a difference.

              My client code i.e. MessageListener looks like this:

              public class FMEventSubscriber implements MessageListener {
               public void onMessage(Message message) {
               if ( message instanceof ObjectMessage){
               ObjectMessage objMessage = (ObjectMessage)message;
               Integer responseMsgType;
               try {
               handleFMEvent(responseMsgType, objMessage.getObject() );
               }catch (Exception e ){
               log.error("Un-Expected error in message processing. ..");
               log.error("Unknow type of FM message receiv...");

              Here, handleFMEvent calls other sessionbeans.
              I have noticed that if I comment out the call to handleFMEvent() then the message processing is fast. But, the main question here is that it(consumer) should not block a producer.

              Do I have the queue up the messages myself and then have a QueueEventprocessor publish the messages in a background thread?


              • 4. Re: Slow consumer is blocking producer
                Yong Hao Gao Master


                I did a simple test and I couldn't see there is a problem. I used the topic example in JBM 1.x with some changes. I sent 40k messages and had a message listener. In its onMessage() I gave a 5 sec sleep.

                Tests shows in about 10 sec all messages have been sent while at the receiving end only two messages was arrived.

                Do you have a test to reproduce this?


                • 5. Re: Slow consumer is blocking producer
                  Poonam Agarwal Newbie

                  Sorry gaohoward,

                  I do not have a performance test to reproduce this. I reproduce this manually.

                  1. Are you sending 40k messages inside a loop in TopicExample.
                  I mean do you do createConnection before you publish every message or are you re-using the connection object before you publish every message.
                  I had tried caching these objects but did not get any improvement.
                  Is it possible for you to send me the modified version of the TopicExample?

                  2. Another difference I have is : I am using

                  session.createObjectMessage(). Is this making the publish process slow?
                  I have custom objects to be send in messages. Does the message type really matter?

                  I am still puzzled with one fact, if I comment the processing logic of each message then the whole process gets faster. I invoke some session beans to do some calculations on receiving each message.

                  Any help is appreciated.