7 Replies Latest reply on Mar 22, 2012 2:42 PM by Christian Spiewok

    How to delete messages from a queue in AS7?

    Christian Spiewok Newbie

      Hello,

      for hours I'm now trying to find a way to delete messages from a JMS queue. I'm looking for someting like "deleteAllMessages" which was (obviously) available through the jmx console. But since there is no jmx console in AS7 any longer, all the information one can find in the internet is useless. I did already take a look in the management console up and down, start the jconsole and the cli, but nowhere there is a way to manage the queues. Is this something which is just not ready yet in AS7 or has it been forgotten or is there just another brilliant way how to manage the queues and delete the messages in it which is not documented (or I didn't find)?

       

      Thanks!

      Christian

        • 1. Re: How to delete messages from a queue in AS7?
          jaikiran pai Master

          Christian, welcome to the forums!

           

          I haven't checked the admin console to see if it exposes this operation, but the management APIs of messaging subsystem does expose it and it's available in the CLI. Start the server with messaging subsystem (ex: the standalone-full.xml) and using the CLI you can see the remove-messages operation description:

           

          [standalone@localhost:9999 /] /subsystem=messaging/hornetq-server=default/jms-queue=testQueue:read-operation-description(name=remove-messages)
          {
              "outcome" => "success",
              "result" => {
                  "operation-name" => "remove-messages",
                  "description" => "Remove messages matching the given filter from the destination.",
                  "request-properties" => {"filter" => {
                      "description" => "A queue message filter definition. An undefined or empty filter will match all messages.",
                      "type" => STRING,
                      "required" => false,
                      "nillable" => true
                  }},
                  "reply-properties" => {
                      "description" => "The number of removed messages.",
                      "type" => INT
                  },
                  "read-only" => false
              }
          }
          

           

          So the remove-messages is what you are looking for. There's also a remove-message operation. Check its description to see if that fits your need.

          • 2. Re: How to delete messages from a queue in AS7?
            Christian Spiewok Newbie

            Hello Jaikiran,

            thank you very much for your answer. This was exactly what I was looking for.

             

            Regards,

            Christian

            • 3. Re: How to delete messages from a queue in AS7?
              Christian Spiewok Newbie

              Hello again,

              maybe I was a little bit too enthusiastic....I did try to call the method on my queue but the result was:

              {

                  "outcome" => "success",

                  "result" => 0

              }

               

              ....and the messages were still processing.

               

              In the admin-application I could see that there are about 2656 messages in queue and the same amount in delivery. So the conclusion is: The "remove-messages" method will not delete messages which are "in delivery". But actually I want to delete this messages or, in other words, stop the processing of any message in the queue at all. So the question is, if "remove-messages" is really what I'm looking for or if there is something like "stop-the-processing-of-any-message-in-the-queue-whether-they-are-in-delivery-or-not". :-)

               

              Regards,

              Christian

              • 4. Re: How to delete messages from a queue in AS7?
                Justin Bertram Master

                Messages which are being delivered have been received by a consumer but have not yet been acknowledged.  There is no way to recall these messages from clients, and I don't believe you'd want to since it is the consumer's prerogative to receive a message and then acknowledge it after it is finished processing it.

                • 5. Re: How to delete messages from a queue in AS7?
                  Christian Spiewok Newbie

                  Hm. Yes, I understand. But the situation is the following: I have started the client and have delivered about 15'000 messages to the queue. Immediately, all the messages's status went to "in delivery". The beans in this case just had a small test method which had a timeout of five seconds. Beside that it took a very long time for the 15'000 messages to be delivered, nothing bad happend.

                   

                  But in a real world situation this could have been emails. Or delete statements. Or, or or....and if the messages were created by error, if I understood you right, there is no way to stop the delivery of the, say, 15'000 messages in any way and every single email, every single select would have been delivered.

                   

                  Did I understand this right? Or is there maybe another way for stopping the messages (Beside deleting and creating a new queue with a new name)?

                  • 6. Re: How to delete messages from a queue in AS7?
                    Justin Bertram Master

                    As I said, messages which are being delivered have been received by a consumer but have not yet been acknowledge.  In general, this cannot be reversed. 

                     

                    One factor in this equation is the consumer-window-size which controls how many messages a client will buffer.  This is because messages in a client's buffer are considered to be in the "being delivered" state.

                     

                    I believe the only thing you can do to help your particular situation is to reduce the consumer-window-size to 0 so that clients will not pre-fetch messages and therefore those messages can be deleted on the server-side.  Of course, that will come at a (perhaps heavy) cost to performance.  Perhaps you could tune the consumer-window-size to balance performance with the ability to account for mistakes.

                     

                    Your best bet is to not send the wrong messages.

                    • 7. Re: How to delete messages from a queue in AS7?
                      Christian Spiewok Newbie

                      Hm. Well. On the one hand it is perfekt like it is. Because of the reliability this mechanism provides. On the other hand it comes with a cost of loosing the full control of how the things are happing. Well, I will need to think about it and see what impact this has on my architectural strategy.

                       

                      ....for your sure, your are right 100%! The best option is not to send the wrong messages at all! ;-)

                       

                      Thank you very much for your quick response!