3 Replies Latest reply on May 15, 2009 10:18 AM by Stan Lewis

    Message not removed from ActiveMQ queue

    Ankit Vernekar Newbie

      Hi folks,

                 I have a servicemix file poller running.It has a JMS file component that puts a xml file on the activemq queue.I implemented a listener to receive this xml from the queue.The listener retrieves the xml successfully but the message does not get deleted from the queue once the xml is read.The implementation for listener is as follows

       

      public void start()

           {

                System.out.println("Inside start.");

                try

                {

                conFac=new ActiveMQConnectionFactory();

                con=conFac.createConnection();          

                session=con.createSession(false, Session.AUTO_ACKNOWLEDGE);

                con.start();

                Destination destination = new ActiveMQQueue("PaymentsXML");          

                consumer=session.createConsumer(destination);

                consumer.setMessageListener(this);          

                System.out.println("start ended");          

                }

                catch(Exception e)

                {

                     System.out.println(e.getMessage());

                }

           }

       

      public void onMessage(Message msg)

           {

                System.out.println("On Message on");

                try {

                     TextMessage tmsg=(TextMessage)msg;

                     String output=tmsg.getText();

                     Transformer t=new Transformer();

                     String result=t.XMLtoXML(output);

                     System.out.println("---Output---");

                     System.out.println(result);

                     System.out.println("---xxxxxx---");

                     PrintWriter pr=new PrintWriter("C:
      Documents and Settings
      PMC
      Desktop
      output.xml");

                     pr.write(result);

                     pr.close();               

                     

                } catch (Exception e) {

                     System.out.println(e.getMessage());

                }

      }

       

      onMessage methods reads the message from the queue.By default the message should get deleted from the queue once read.

      Am I going wrong somewhere? if so please help

      Versions used

      ActiveMQ 5.2.0

      JDK 1.6

      Windows XP

       

      Regards,

      Ankit Vernekar