6 Replies Latest reply on Dec 20, 2010 7:21 AM by jacker

    How to handle a message queue?

    jacker

      Hi folks. I'm trying to manipulate a jms queue. I have a MDB listening to, with this configuration:

       

      @ActivationConfigProperty(propertyName = "maxSession", propertyValue = "1")
      

       

      Now imagine this scenario:

       

      A client sending a lot of messages:

           publisher.send(message1);
           publisher.send(message2);
           publisher.send(message3);
           publisher.send(message4);
           publisher.send(message5);
      
      

       

      MDB is processing just one per time:

           onMessage(Message message){
      
                System.out.println("Message " + message + " received");
      
                try {
                     Thread.sleep(10000);
                } catch (InterruptedException e) {
                     e.printStackTrace();
                }          
      
                System.out.println("Done!");
      
           }
      

       

      Now the client need cancel the message3, because it was dispatched wrong. How can I do that without remove all of the queue?

       

      I've tried to delete it from JBM_MSG table, but it continues to being delivered. BTW I'm using JBoss 5.1.0 and default messaging service. Thanks.

        • 1. Re: How to handle a message queue?
          wdfink

          A simple way to do this is to use a QueueBrowser to check the queue, after you know the correct one you are able to consume it with a message selector for exact this message (e.g. the message id) or the client know the necessary message properties.

          • 2. Re: How to handle a message queue?
            jacker

            Thanks for your answer Wolf. I'm trying that way but it has no messages in queue. I think it was already buffered, maybe I have to set consumer-window-size to zero, but i dunno where i set this parameter. What do you think?

            • 3. Re: How to handle a message queue?
              jacker

              Just to complement, i tried to "Remove All Messages" by Admin-Console and JBoss failed to do that. It returns me:

               

              "removeAllMessages java.lang.IllegalStateException: Cannot remove references while deliveries are in progress (Channel 1), there are 5"

              • 4. Re: How to handle a message queue?
                wdfink

                I never tried AdminConsole for this.

                The application read via QueueBrowser it's own messages display it and the user is able to drop unprocessed messeges.

                This is done by a normal consuming with a special message selector.

                You never see messages which are in progress by the 'normal' processing

                • 5. Re: How to handle a message queue?
                  jacker

                  I've tried to implement de QueueBrowser but it seems doesn't work. My project example is on this link:

                   

                  http://www.beholder.com.br/download/rr-jms-ejb3.zip

                   

                  Thanks.

                  • 6. Re: How to handle a message queue?
                    jacker

                    I've found an answer for my question.

                     

                    It is not possible to handle a message who's being delivered. I've tried to set the consumer window to zero, and a lot of other things. I've been studing a solution for case about a week, googling all possibilities but it cannot be done. Actually I've found the class who operate this channel between producer and consumer, but there a lot of comments sugesting to not alter the code to ensure integrity.

                     

                    Thanks.