From 0826fdcf0645016f4a88fc785aaa21dce5855f75 Mon Sep 17 00:00:00 2001 From: "Timothy A. Bish" Date: Fri, 19 Jul 2013 18:21:09 +0000 Subject: [PATCH] AMQ-4637 fix test that fails due to this change, also remove extra call to setPoisonCause git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1504954 13f79535-47bb-0310-9956-ffa450edef68 --- .../activemq/ActiveMQMessageConsumer.java | 1 - .../MessageListenerRedeliveryTest.java | 42 +++++++++---------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java b/activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java index b7f6aff1db..da4b1d16b2 100755 --- a/activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java +++ b/activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java @@ -1206,7 +1206,6 @@ public class ActiveMQMessageConsumer implements MessageAvailableConsumer, StatsC // Acknowledge the last message. MessageAck ack = new MessageAck(lastMd, MessageAck.POSION_ACK_TYPE, deliveredMessages.size()); - ack.setPoisonCause(lastMd.getRollbackCause()); ack.setFirstMessageId(firstMsgId); ack.setPoisonCause(new Throwable("Exceeded redelivery policy limit:" + redeliveryPolicy)); session.sendAck(ack,true); diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/MessageListenerRedeliveryTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/MessageListenerRedeliveryTest.java index 61076dba9c..798cb2ac6b 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/MessageListenerRedeliveryTest.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/MessageListenerRedeliveryTest.java @@ -47,6 +47,7 @@ public class MessageListenerRedeliveryTest extends TestCase { private Connection connection; + @Override protected void setUp() throws Exception { connection = createConnection(); } @@ -54,6 +55,7 @@ public class MessageListenerRedeliveryTest extends TestCase { /** * @see junit.framework.TestCase#tearDown() */ + @Override protected void tearDown() throws Exception { if (connection != null) { connection.close(); @@ -80,12 +82,13 @@ public class MessageListenerRedeliveryTest extends TestCase { private class TestMessageListener implements MessageListener { public int counter; - private Session session; + private final Session session; public TestMessageListener(Session session) { this.session = session; } + @Override public void onMessage(Message message) { try { LOG.info("Message Received: " + message); @@ -125,7 +128,6 @@ public class MessageListenerRedeliveryTest extends TestCase { try { Thread.sleep(500); } catch (InterruptedException e) { - } // first try.. should get 2 since there is no delay on the @@ -135,7 +137,6 @@ public class MessageListenerRedeliveryTest extends TestCase { try { Thread.sleep(1000); } catch (InterruptedException e) { - } // 2nd redeliver (redelivery after 1 sec) assertEquals(3, listener.counter); @@ -143,7 +144,6 @@ public class MessageListenerRedeliveryTest extends TestCase { try { Thread.sleep(2000); } catch (InterruptedException e) { - } // 3rd redeliver (redelivery after 2 seconds) - it should give up after // that @@ -156,7 +156,6 @@ public class MessageListenerRedeliveryTest extends TestCase { try { Thread.sleep(500); } catch (InterruptedException e) { - // ignore } // it should be committed, so no redelivery assertEquals(5, listener.counter); @@ -164,7 +163,6 @@ public class MessageListenerRedeliveryTest extends TestCase { try { Thread.sleep(1500); } catch (InterruptedException e) { - // ignore } // no redelivery, counter should still be 4 assertEquals(5, listener.counter); @@ -239,7 +237,7 @@ public class MessageListenerRedeliveryTest extends TestCase { public void testQueueSessionListenerExceptionRetry() throws Exception { connection.start(); - + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = session.createQueue("queue-" + getName()); MessageProducer producer = createProducer(session, queue); @@ -247,15 +245,15 @@ public class MessageListenerRedeliveryTest extends TestCase { producer.send(message); message = createTextMessage(session, "2"); producer.send(message); - - + MessageConsumer consumer = session.createConsumer(queue); - + final CountDownLatch gotMessage = new CountDownLatch(2); final AtomicInteger count = new AtomicInteger(0); final int maxDeliveries = getRedeliveryPolicy().getMaximumRedeliveries(); final ArrayList received = new ArrayList(); consumer.setMessageListener(new MessageListener() { + @Override public void onMessage(Message message) { LOG.info("Message Received: " + message); try { @@ -272,9 +270,9 @@ public class MessageListenerRedeliveryTest extends TestCase { gotMessage.countDown(); } }); - + assertTrue("got message before retry expiry", gotMessage.await(20, TimeUnit.SECONDS)); - + for (int i=0; i