activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mjustin <>
Subject Stomp ack:auto clears all remaining messages in the queue
Date Thu, 16 Apr 2009 09:37:26 GMT


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

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

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;

        frame = stompConnection.receiveFrame();

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

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

        frame = "DISCONNECT\n" + "\n\n" + Stomp.NULL;

        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:
Sent from the ActiveMQ - User mailing list archive at

View raw message