javax.jms.JMSException: Could not correlate acknowledgment with dispatched 
message thrown on failover
-----------------------------------------------------------------------------------------------------

                 Key: AMQ-2125
                 URL: https://issues.apache.org/activemq/browse/AMQ-2125
             Project: ActiveMQ
          Issue Type: Bug
          Components: Broker
    Affects Versions: 5.2.0
         Environment: MacOS 10.5 and Solaris 10
            Reporter: Team Hiro


When failing over to a new broker we see this exception. Although the exception 
is thrown no messages seem to be lost.

This can be reproduced using the following unit test and this setup:
1. Create two activemq's using the same datasource.
2. Run the test
3. Kill the first active mq before the test completes (after you see the first 
Recieved Message... in the system out)
4. See the exception thrown in the second activemq log

import org.apache.activemq.ActiveMQConnectionFactory;

import javax.jms.*;
import static javax.jms.Session.AUTO_ACKNOWLEDGE;
import static javax.jms.Session.SESSION_TRANSACTED;

import junit.framework.TestCase;

import java.util.concurrent.atomic.AtomicInteger;

public class BrokerTest extends TestCase {

    public void testFoo() throws Exception {
        ConnectionFactory connectionFactory = new 
ActiveMQConnectionFactory("failover:(tcp://localhost:61616,tcp://localhost:61617)");

        Connection connection = connectionFactory.createConnection();
        connection.start();

        Session producerSession = connection.createSession(false, 
AUTO_ACKNOWLEDGE);

        MessageProducer producer = 
producerSession.createProducer(producerSession.createQueue("testQueue"));

        for (int i = 0; i < 100; i++) {
            System.out.println("Sending messages");
            producer.send(producerSession.createTextMessage("Hello"));
        }

        final AtomicInteger atomicInteger = new AtomicInteger(0);

        final Session consumerSession = connection.createSession(true, 
SESSION_TRANSACTED);
        MessageConsumer messageConsumer = 
consumerSession.createConsumer(consumerSession.createQueue("testQueue"));
        messageConsumer.setMessageListener(new MessageListener() {



            public void onMessage(Message message) {
                try {
                    System.out.println("Received Message" + message);
                    Thread.sleep(1000);
                    atomicInteger.addAndGet(1);
                    System.out.println(atomicInteger.get());
                    consumerSession.commit();
                } catch (Exception e) {
                    throw new RuntimeException("Oh dear", e);
                }
            }
        });

        Thread.sleep(2 * 60 * 1000);

        assertEquals(100, atomicInteger.get());
    }

}



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to