4 Replies Latest reply on May 12, 2011 1:45 PM by cjiras

    can't remove messages while consuming messages on the same queue.

    cjiras

      I'm using jboss 6.0.0.Final (with the embedded hornetq 2.1.2.Final).

      I can produce and consume ObjectMessages without any problems on myQueue through the jboss container.

       

      I can removeMessages on myQueue with a selector using the JMSQueueControl without any probems as long as I don't have a messageBean listening to myQueue. As soon as I startup jboss with a messageBean listening to myQueue I can't removeMessages on myQueue (it comes back a 0 removed though I know I have plenty messages in the queue that I can remove).

       

      This is also true when I go through the JBoss JMX Management console.

      I can get a list of messages (using the listMessageAsJSON operation) and remove messages (using removeMessages operation) as long as I don't have a messageBean listening to myQueue. As soon as a messageBean is configured to listen to the queue OR if I start up a client messageListener to consume message from myQueue, I can no longer removeMessages or list messages through the JMX Management console.

       

      It seems that I might need to configure something with hornetq or my messageBean to allow me removeMessages and consume message on the same queue. Note: I did set my messageBean's maxSession to 1.

       

      Inside the JMX console, when ConsumerCount=0, I can remove messages. When ConsumerCount=1 (or more), I can't remove messages.

       

      For example:

      1) I produce 40 messages onto MyQueue.

      2) I have no consumers running.

      3) I go to the JMX console and I can see all the messages on MyQueue.

      4) I can list all the messages with the JMX operation listMessagesAsJSON.

      5) I can remove a message with a filer using the JMX operation removeMessages (the removeMessages operation returns with result of 1).

      6) I can verify that the message was removed by listing the messages again with listMessagesAsJSON.

      7) I startup a MessageListener client and it begins to consume messages (about one every five minutes).

      8) I go back to the JMX console and try to list all the messages with the JMX operation listMessagesAsJSON, but an empty array is returned.

      9) I try to remove a message with a filter using the JMX operation removeMessages, but the operation returns a result of 0).

      10) I then shutdown the client MessageListener.

      11) I can now list all the messages with the JMX operation listMessagesAsJSON.

      12) I can now remove a message with a filer using the JMX operation removeMessages.

       

      When I connect a messageListener, is seems to block all QueueController requests.

      Is this the expected default behavior?

      I've done minimal custom setup with basic "out of the box" configurations for both the queue and messagebeans.

       

      Basically, it seems to me that I should be able to connect a client messageListener AND be able to removeMessages via QueueController on the same queue at the same time without having to shutdown the client messageListener first to remove specific messages.

       

      Any ideas...

        • 1. can't remove messages while consuming messages on the same queue.
          clebert.suconic

          Any message system I know out there will have a feature like: fetch ahead, read ahead, cache at the client... or whatever other name they chose at their docs.

           

          While doing so, the message that are on the client's buffer (client consumer) can't be accessed by any other consumer or management operation. The message will be in "delivering state" and it can't be deleted while doing that.

           

           

          If you can afford the performance burden of disabling caching at the client, you can set consumerWindowSize=0 and you will be able to delete messages even while consuming. But you will require a TCP roundtrip for each message you receive, that means your performance will be bound to your network latency.

          • 2. can't remove messages while consuming messages on the same queue.
            leosbitto

            Clebert Suconic wrote:

             

            Any message system I know out there will have a feature like: fetch ahead, read ahead, cache at the client... or whatever other name they chose at their docs.

             

            While doing so, the message that are on the client's buffer (client consumer) can't be accessed by any other consumer or management operation.

             

            I actually know a JMS system which shows the messages in the clients' buffers in the management operations, properly marked as being in the client cache (locked, not accessible for any modification). Is there any possibility to get this information (about the messages in the clients' buffers) from HornetQ management API?

            • 3. can't remove messages while consuming messages on the same queue.
              clebert.suconic

              There's a delivering messages counter at the queue management

              • 4. Re: can't remove messages while consuming messages on the same queue.
                cjiras

                Thanks Clebert for your answer!

                 

                I was able to successfully remove messages from my queue with an active message consumer by setting the consumer window size to zero.

                In my situtation, I can do this because the message consumer takes a relatively long time to finish a message (5 - 20 minutes) and the extra roundtrip on the network is not a big issue.

                 

                In summary, the fix is as follows:

                I updated my hornetq-jms.xml with new consumer-window-size configuration elements set to zero for each connection-factory element.

                <connection-factory ...>

                ...

                <consumer-window-size>0</consumer-window-size>

                </connection-factory>

                 

                Note: the update of the hornetq-jms.xml configuration files only effect messageListeners outside of the container, for changes that effect the messageBeans in the container you need to change the configuration of the JCA adapter.

                 

                Thanks!