0 Replies Latest reply on Sep 8, 2010 2:17 AM by bizz

    Removing message from a queue with a servlet

    bizz

      Hi,

       

      I'm trying to create a servlet which enables it's users to delete messages from a queue.

      My code is working when I run it as standalone but it is not working when I execute it as a servlet. (Although I do get a positive reply from my request the messages are not actually removed from the queue)

       

      I guess there is something I should do different since it's a servlet but I'm not sure what it is.

       

      My code:

      InitialContext context = getContext();   // Same context used to send a message using a servlet - which works
      QueueConnectionFactory cf = (QueueConnectionFactory)context.lookup("/ConnectionFactory");
      QueueConnection connection = cf.createQueueConnection("user", "password");
      connection.start();   
      QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);           
      Queue managementQueue = HornetQJMSClient.createQueue("hornetq.management");
      QueueRequestor requestor = new QueueRequestor(session, managementQueue);           
             
      Message m = session.createMessage();
      JMSManagementHelper.putOperationInvocation(m,
                      "jms.queue.myQueue",
                      "removeMessages", filter);
      Message reply = requestor.request(m);
      boolean success = JMSManagementHelper.hasOperationSucceeded(reply);         


      result:

      success is true, but the messages are still in the queue.

       

      I'm using version 2.1.2.

       

      I'll appreciate any help

      Thanks