Message is not removed/ not auto acknowledged from HornetQ

845 Views Asked by At

Am first time using Jboss 7.2 and am trying to deploy a simple MDB . The MDB is annotated for auto acknowledgment

@MessageDriven(activationConfig = {
    @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "auto-acknowledge"),
    @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
    @ActivationConfigProperty(propertyName = "destination", propertyValue = "/queue/test")
    })
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
@TransactionManagement(value= TransactionManagementType.CONTAINER)
public class TextMessageListener implements MessageListener {

onMessage is simple , just sleep and awake. My expectation is as soon as message is consumed by MDB i.e onMessage is invoked , it should be removed from Queue. But the message remains in the queue until onMessage is completed and the status shows as "In Delivery".

public void onMessage(Message message) {
    System.out.println("sleeping for some time");
    try {
        Thread.sleep(10*60000);
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    System.out.println("awake and done now");
}

When the on-message is completed , the log shows acknowledgment is sent AFTER completion and hence message is deleted from queue after onMessage completes. Some stupid silly configuration somewhere as it is quite simple to do. .. but any idea what is missing. How to set autoacknowledgment in JBOSS 7.2 MDB such that message is auto-ack as soon as onMessage is invoked.

15:59:33,584 INFO  [stdout] (Thread-3 (HornetQ-client-global-threads-467768789)) awake and done now


15:59:33,586 DEBUG [org.hornetq.core.client] (Thread-3 (HornetQ-client-global-threads-467768789)) client ack messageID = 1079

This is something simple straight forward but its not working as expected. We tried with a consumer ( a standalone java test client to read message from queue) and its working there.

As soon as message is consumed by consumer its deleted from queue even though message is in processing by consumer but not in MDB.

Any idea ?

I have tried to ask the same question in JBoss community but no success. Hopefully someone will answer here..

Thanks in advance.

1

There are 1 best solutions below

0
On

I was trying something similar on Glassfish (v4.0) and noticed my mdb had problems deploying (I had a verifier running). The glassfish log file complained about an unrecognized propertyvalue of "auto-acknowledge". I made the following change and then it worked:

Change From: propertyValue = "auto-acknowledge")

Change To: propertyValue = "Auto-acknowledge")

Note the capitalization - which was changed to match the listing in the ejb3.2 spec (section 5.4.16.1).