Transacted AMQP consumer to a queue does not acknowledge messages consumed

Solution Unverified - Updated -

Issue

A simple test case with a AMQP consumer using a transacted JMS session session = con.createSession(true,Session.AUTO_ACKNOWLEDGE); shows that the consumer is not acknowledging message consumption properly. Hence, the messages continue to remain on the queue even after the consumer has processed all of them.

The consumer does issue session.commit() after processing the messages. However, it does not seem to direct the broker to remove the messages from the queue.

Code snippet is below.

        try{
            connectionFactory =
                new ConnectionFactoryImpl(hostName,port,userName,password,clientId,hostName,false);
            con = connectionFactory.createConnection();
            session = con.createSession(true,Session.AUTO_ACKNOWLEDGE);
            con.start();
            queue = session.createQueue(destinationName);
            String msgSelector="type = '1'";
            mc = session.createConsumer(queue,msgSelector);
            for(int i=0;i<10;i++){
                TextMessage tm = (TextMessage)mc.receive(1000);
                System.out.println("Text message Received " + tm.getText());
            }
            session.commit();
        }catch(Exception e){
            e.printStackTrace();
        }finally{
            try{
                if(session != null){
                    session.close();
                }
                if(mc != null){
                    mc.close();
                }
                if (connectionFactory != null){
                        con.stop();
                        con.close();
                }
            }catch(Exception jmsE){
                jmsE.printStackTrace();
            }

        }

Environment

JBoss A-MQ 6.0
AMQP Transport

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content