Hello,

I am writing a small unit test of durable subscriber on ActiveMQ 5.1. I
found this error is happening consistently the second time I ran this test
case.

ERROR RecoveryListenerAdapter        - Message id ID:XXXX could not be
recovered from the data store - already dispatched

The program I have:

        @Test
        public void testConsumeDurableTopic() {         
                try {
                        //Start durable subscriber
                        this.startSubscriberSeparately(durableSubscriber);
                        //Send a message
                        this.produceMessage(true);

                        
                        this.produceMessage(true);
                        System.out.println("Should receive the message sent 
during the
downtime---------------");
                        //Start durable subscriber after sending message
                        this.startSubscriberSeparately(durableSubscriber);


                        durableSubscriber.unsubscribe();
                        
                        this.produceMessage(true);
                        this.startSubscriberSeparately(durableSubscriber);
                        System.out.println("Should NOT receive the message sent 
after
unsubscribe-------------");
                
                } catch(Exception e) {
                        e.printStackTrace();
                        fail("Fail to consume messages from 
testConsumeDurableTopic().");
                }               
        }       
        /**
         * Start the topic subscriber in a separate thread. It tries to receive 
one
message and block until receiving it.
         */
        protected void startSubscriberSeparately (final 
SynchronizedMessageConsumer
consumer) {
        final Runnable starter = new Runnable() {
            public void run() { 
                        try {
                                consumer.receive(topic);
                                } catch (ConsumerFailureException e) {
                                        e.printStackTrace();
                                        fail("Fail to start the consumer on a 
separate thread.");
                                }                       
            }
        };
        final ExecutorService pool = Executors.newFixedThreadPool(1);
        pool.execute(starter);
        }       

The first run is fine. Then the second run would cause "ERROR
RecoveryListenerAdapter". Then I cannot receive any message from that topic
any more. What's the cause for this error? I guess the reason is that the
message is prefetched to the client side, then that message could not be
recovered from the data store. However, connecting to the broker
"tcp://localhost:61616?jms.prefetchPolicy.topicPrefetch=1" doesn't fix the
problem. Any input is very much appreciated.

-- 
View this message in context: 
http://www.nabble.com/%22ERROR-RecoveryListenerAdapter%22-happens-on-a-durable-subscriber-tp19379169p19379169.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to