Hello,

I compared the behaviour of the JMS client (using the ProducerTool and
ConsumerTool) and the behaviour of the Stomp client in Java.

In both tests I start with 20 messages which I send to the queue
TOOL.DEFAULT:


call java -cp .;activemq-all-5.3-SNAPSHOT.jar ProducerTool --MessageCount=20

Then I verify that the queue contains 20 messages:

start http://localhost:8161/admin/browse.jsp?JMSDestination=TOOL.DEFAULT

First I run the test of the JMS Client, consuming 10 messages using
AUTO_ACKNOWLEDGE: 

java -cp .;activemq-all-5.3-SNAPSHOT.jar ConsumerTool
--AckMode=AUTO_ACKNOWLEDGE --MaxiumMessages=10 --verbose

Then I verify that there are 10 messages remaining in the queue, with the
'Redelivered' fag set.

Finally I read the remaining queue entries using the same command as before.

Now I start again, sending 20 messages to the queue.

With the Stomp Java client, I read ten messages:

    public void testSubscribeWithAutoAck() throws Exception {

        String frame = "CONNECT\n" + "login: system\n" + "passcode:
manager\n\n" + Stomp.NULL;
        stompConnection.sendFrame(frame);

        frame = stompConnection.receiveFrame();
        System.out.println(frame);

        frame = "SUBSCRIBE\n" + "destination:/queue/TOOL.DEFAULT" + "\n" +
"ack:auto\n\n" + Stomp.NULL;
        stompConnection.sendFrame(frame);

        for (int i=0; i < 10; i++) {
          frame = stompConnection.receiveFrame();
            System.out.println(frame);
        }

        frame = "DISCONNECT\n" + "\n\n" + Stomp.NULL;
        stompConnection.sendFrame(frame);

        System.out.println("Disconnect frame sent");
    }


Now I check the queue in the admin console: there should be ten remaining
messages in the queue, but the queue is empty.

All 20 messages have been sent to the client over the Stomp adapter (as I
can see in the broker log), but the broker does not realize that the client
has received only 10.

So the difference between the JMS and the Stomp interface is that the JMS
interface allows to fetch some messages using automatic acknowledge, while
the Stomp client (using ack:auto) would require to read all remaining
messages - if it stops receiving, all remaining messages are lost.

I am not sure if this is 'as designed', however it seems to make automatic
acknowledgement in the Stomp interface very fragile.

Best Regards
Michael Justin
-- 
View this message in context: 
http://www.nabble.com/Stomp-ack%3Aauto-clears-all-remaining-messages-in-the-queue-tp23074533p23074533.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to