3 Replies Latest reply on Apr 23, 2014 2:39 PM by jbertram

    calling consumer.receive() doesn't delete the message

    yairogen

      Using the core API I can't manage to read a message and effectively remove it from the server. This happens even though I create the session with AutoAck.

       

      What am I missing?

        • 1. Re: calling consumer.receive() doesn't delete the message
          jbertram

          Can you share you're client code?

          • 2. Re: Re: calling consumer.receive() doesn't delete the message
            yairogen

            This code prints the same message no matter how many times I tun it.

             

            ClientSessionFactory nettyFactory = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(NettyConnectorFactory.class.getName())).createSessionFactory();
            
            
                    ClientSession session = nettyFactory.createSession(true,true);
            
            
                    session.start();
            
            
                     ClientConsumer consumer = session.createConsumer("example");
            
            
                    ClientMessage msgReceived = consumer.receive();
            
            
                    System.out.println("message = " + msgReceived.getBodyBuffer().readString());
            
            
                    session.close();
            
            • 3. Re: Re: Re: calling consumer.receive() doesn't delete the message
              jbertram

              You aren't acknowledging the message.  You have to call org.hornetq.api.core.client.ClientMessage.acknowledge() to remove the message from the server.

               

              Furthermore, when you call:

               

              ClientSession session = nettyFactory.createSession(true,true);
              

               

              You are creating a session that will auto-commit sends and acks.  In other words, you don't have to call org.hornetq.api.core.client.ClientSession.commit() to complete a send or acknowledgement.  However, for acknowledgements you still have to call acknowledge().