7 Replies Latest reply on Jun 26, 2011 11:19 AM by grgptch

    ack messages individually

    grgptch

      hi everyone,

       

      is it possible to ack messages in a queue individually eventhough they are of same priority? i'd like to be able to consume messages from the queue in some random orther. tried playing with setAckBatchSize but it would always ack batch of messages if i tried to consume messages that are not at queue head.

       

      serverLocator.setAckBatchSize(1);

      factory.createSession(user, password, false, true, true, false, 1);

       

      thanks.

        • 1. Re: ack messages individually
          ataylor

          is it possible to ack messages in a queue individually eventhough they are of same priority?

          Im not really sure what you mean by this, however when a message is acked it acks that message plus evry message thats been consumed but not acked before it.

          • 2. Re: ack messages individually
            grgptch

            basically i'd like to consume messages in some random order from teh queue. let's say i have 10 messages in the queue: 1, 2, 3, 4, ...., 10. i'd like to consume just messages 5 and 6 while the rest will still stay in the queue, so i can consume them some time later (again in some random order depending on the application's business logic).

            • 3. Re: ack messages individually
              clebert.suconic

              In JMS terms, an ACK will ack all the previous messages.

               

              We may introduce individual ACK options on the core-api. At this point this is not an option. You may add a JIRA with a feature request if you like.

              • 4. Re: ack messages individually
                grgptch

                Thanks Clebert, will do that.

                • 5. Re: ack messages individually
                  timfox

                  george pitich wrote:

                   

                  basically i'd like to consume messages in some random order from teh queue. let's say i have 10 messages in the queue: 1, 2, 3, 4, ...., 10. i'd like to consume just messages 5 and 6 while the rest will still stay in the queue, so i can consume them some time later (again in some random order depending on the application's business logic).

                  Seems like you want to use the message queueing system like a database.

                  • 6. Re: ack messages individually
                    ataylor

                    Tim is rigt, if you dont want some sort of ordering then why use a queue, i would just write to a database.

                    • 7. Re: ack messages individually
                      grgptch

                      makes sense what you guys are saying. i was just exploring the above mentioned option in a queue scenario. requirement was to use the queue mechanism instead of distributed db which was first obvious mentioned solution.

                       

                      i tried removing messages from the queue (http://community.jboss.org/thread/168298?tstart=0) in some random order and it worked (jmx) provided queue has never been read (consumed without acking). once you read the queue (consume with no acking, messages stay in the queue), "boolean removeMessage(long messageID)" always removes first message in the queue? i was expecting that as long as you provide correct message messageID, hornetq would remove it regardless of whether queue has been read or not (no ack).