6 Replies Latest reply on Jul 15, 2004 9:30 AM by adrian.brock

    Remove JMS Message

    nort

      Hello,

      does anyone knows how to remove (or consume) a specific JMS-message from a queue?

      Thanks,
      Juraj

        • 1. Re: Remove JMS Message
          darklord

          identify your message with a selector. Describe what is a specific JMS message for you.

          Regards,

          Stephane

          • 2. Re: Remove JMS Message
            nort

            I want to remove a message with a special content for example. Is there a possibility to remove a message from the queue (not to consume it)?

            • 3. Re: Remove JMS Message
              schrouf

              There is no way - at least no portable, non-dirty workaround - to remove a message from a queue other than consuming it. But where's the problem ? Include your content based detection logic in the consuming queue client ! Based on that logic you can drop the message or proceed with processing ! Most probably you also should rethink your application logic...

              • 4. Re: Remove JMS Message
                nort



                I trie it with the following lines of code. I identifie the specific message and get the message-id. Then I create a QueueReceiver to consume this message. But I get still "null" message. Dos anyone see an error? The message is within the queue, definitly. Also the JMX Bean of the queue listens the message.

                InitialContext initialContext = new InitialContext(connProps);
                mqFactory = (QueueConnectionFactory) initialContext.lookup("ConnectionFactory");
                Queue wfQueue = (Queue) initialContext.lookup("queue/my-queue");
                QueueConnection qConn = mqFactory.createQueueConnection();
                QueueSession qSession = (QueueSession)qConn.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);

                QueueReceiver qRec = qSession.createReceiver(wfQueue, "JMSMessageID like \'%14-10898887709371%\'");
                Message m = (Message)qRec.receive(3000);

                qRec.close();
                qSession.close();
                qConn.close();

                • 5. Re: Remove JMS Message
                  nort

                  With these lines of code, I get the following stack on server side:

                  QueueReceiver qRec = qSession.createReceiver(wfQueue, null);
                  MapMessage m = (MapMessage)qRec.receive(3000);
                  InitialContext initialContext = new InitialContext(connProps);
                  mqFactory = (QueueConnectionFactory) initialContext.lookup("ConnectionFactory");
                  Queue wfQueue = (Queue) initialContext.lookup("queue/ik-wfqueue");
                  QueueConnection qConn = mqFactory.createQueueConnection();
                  QueueSession qSession = (QueueSession)qConn.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);

                  QueueReceiver qRec = qSession.createReceiver(wfQueue, null);
                  MapMessage m = (MapMessage)qRec.receive(3000);

                  qRec.close();
                  qSession.close();
                  qConn.close();




                  14:36:46,968 DEBUG [StandardWrapper] Returning non-STM instance
                  14:36:50,062 DEBUG [SocketManager$ReadTask] Begin ReadTask.run
                  14:36:50,062 DEBUG [SocketManager$WriteTask] Begin WriteTask.run
                  14:36:50,062 DEBUG [SocketManager$WriteTask] Created ObjectOutputStream
                  14:36:50,093 DEBUG [SocketManager$ReadTask] Created ObjectInputStream
                  14:36:50,109 DEBUG [ServerSocketManagerHandler] Setting up the UILClientIL Connection
                  14:36:50,109 DEBUG [ServerSocketManagerHandler] The UILClientIL Connection is set up
                  14:36:51,968 DEBUG [CoyoteAdapter] Requested cookie session id is 1664A02DD671843F7BCDCAF1ADBFB80F
                  14:36:51,968 DEBUG [StandardWrapper] Returning non-STM instance
                  14:36:53,171 DEBUG [ServerSocketManagerHandler] Exiting on IOE
                  java.net.SocketException: socket closed
                  at java.net.SocketInputStream.socketRead0(Native Method)
                  at java.net.SocketInputStream.read(SocketInputStream.java:129)
                  at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
                  at java.io.BufferedInputStream.read(BufferedInputStream.java:201)
                  at org.jboss.util.stream.NotifyingBufferedInputStream.read(NotifyingBufferedInputStream.java:67)
                  at java.io.ObjectInputStream$PeekInputStream.peek(ObjectInputStream.java:2133)
                  at java.io.ObjectInputStream$BlockDataInputStream.readBlockHeader(ObjectInputStream.java:2313)
                  at java.io.ObjectInputStream$BlockDataInputStream.refill(ObjectInputStream.java:2380)
                  at java.io.ObjectInputStream$BlockDataInputStream.read(ObjectInputStream.java:2452)
                  at java.io.ObjectInputStream$BlockDataInputStream.readByte(ObjectInputStream.java:2601)
                  at java.io.ObjectInputStream.readByte(ObjectInputStream.java:845)
                  at org.jboss.mq.il.uil2.SocketManager$ReadTask.run(SocketManager.java:279)
                  at java.lang.Thread.run(Thread.java:534)
                  14:36:53,171 DEBUG [SocketManager$ReadTask] End ReadTask.run
                  14:36:53,171 DEBUG [SocketManager$WriteTask] End WriteTask.run

                  • 6. Re: Remove JMS Message

                    That is a common newbie error.
                    You cannot receive messages unless you do connection.start() first.