activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1504954 - in /activemq/trunk: activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java activemq-unit-tests/src/test/java/org/apache/activemq/MessageListenerRedeliveryTest.java
Date Fri, 19 Jul 2013 18:21:10 GMT
Author: tabish
Date: Fri Jul 19 18:21:09 2013
New Revision: 1504954

URL: http://svn.apache.org/r1504954
Log:
AMQ-4637 fix test that fails due to this change, also remove extra call to setPoisonCause

Modified:
    activemq/trunk/activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java
    activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/MessageListenerRedeliveryTest.java

Modified: activemq/trunk/activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java?rev=1504954&r1=1504953&r2=1504954&view=diff
==============================================================================
--- activemq/trunk/activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java
(original)
+++ activemq/trunk/activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java
Fri Jul 19 18:21:09 2013
@@ -1206,7 +1206,6 @@ public class ActiveMQMessageConsumer imp
                     // 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);

Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/MessageListenerRedeliveryTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/MessageListenerRedeliveryTest.java?rev=1504954&r1=1504953&r2=1504954&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/MessageListenerRedeliveryTest.java
(original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/MessageListenerRedeliveryTest.java
Fri Jul 19 18:21:09 2013
@@ -47,6 +47,7 @@ public class MessageListenerRedeliveryTe
 
     private Connection connection;
 
+    @Override
     protected void setUp() throws Exception {
         connection = createConnection();
     }
@@ -54,6 +55,7 @@ public class MessageListenerRedeliveryTe
     /**
      * @see junit.framework.TestCase#tearDown()
      */
+    @Override
     protected void tearDown() throws Exception {
         if (connection != null) {
             connection.close();
@@ -80,12 +82,13 @@ public class MessageListenerRedeliveryTe
     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 MessageListenerRedeliveryTe
         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 MessageListenerRedeliveryTe
         try {
             Thread.sleep(1000);
         } catch (InterruptedException e) {
-
         }
         // 2nd redeliver (redelivery after 1 sec)
         assertEquals(3, listener.counter);
@@ -143,7 +144,6 @@ public class MessageListenerRedeliveryTe
         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 MessageListenerRedeliveryTe
         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 MessageListenerRedeliveryTe
         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 MessageListenerRedeliveryTe
 
     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 MessageListenerRedeliveryTe
         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<String> received = new ArrayList<String>();
         consumer.setMessageListener(new MessageListener() {
+            @Override
             public void onMessage(Message message) {
                 LOG.info("Message Received: " + message);
                 try {
@@ -272,9 +270,9 @@ public class MessageListenerRedeliveryTe
                 gotMessage.countDown();
             }
         });
-            
+
         assertTrue("got message before retry expiry", gotMessage.await(20, TimeUnit.SECONDS));
-        
+
         for (int i=0; i<maxDeliveries; i++) {
             assertEquals("got first redelivered: " + i, "1", received.get(i));
         }
@@ -283,11 +281,10 @@ public class MessageListenerRedeliveryTe
         }
         session.close();
     }
-        
 
     public void testQueueSessionListenerExceptionDlq() throws  Exception {
         connection.start();
-            
+
         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
         Queue queue = session.createQueue("queue-" + getName());
         MessageProducer producer = createProducer(session, queue);
@@ -299,6 +296,7 @@ public class MessageListenerRedeliveryTe
         MessageConsumer dlqConsumer = session.createConsumer(dlqDestination);
         final CountDownLatch gotDlqMessage = new CountDownLatch(1);
         dlqConsumer.setMessageListener(new MessageListener() {
+            @Override
             public void onMessage(Message message) {
                 LOG.info("DLQ Message Received: " + message);
                 dlqMessage[0] = message;
@@ -307,20 +305,21 @@ public class MessageListenerRedeliveryTe
         });
 
         MessageConsumer consumer = session.createConsumer(queue);
-            
+
         final int maxDeliveries = getRedeliveryPolicy().getMaximumRedeliveries();
         final CountDownLatch gotMessage = new CountDownLatch(maxDeliveries);
-        
+
         consumer.setMessageListener(new MessageListener() {
+            @Override
             public void onMessage(Message message) {
                 LOG.info("Message Received: " + message);
                 gotMessage.countDown();
                 throw new RuntimeException(getName() + " force a redelivery");
             }
         });
-            
+
         assertTrue("got message before retry expiry", gotMessage.await(20, TimeUnit.SECONDS));
-        
+
         // check DLQ
         assertTrue("got dlq message", gotDlqMessage.await(20, TimeUnit.SECONDS));
 
@@ -328,12 +327,11 @@ public class MessageListenerRedeliveryTe
         message = dlqMessage[0];
         assertNotNull("dlq message captured", message);
         String cause = message.getStringProperty(ActiveMQMessage.DLQ_DELIVERY_FAILURE_CAUSE_PROPERTY);
-        assertTrue("cause exception is remembered", cause.contains("RuntimeException"));
-        assertTrue("is correct exception", cause.contains(getName()));
-        
+        LOG.info("DLQ'd message cause reported as: {}", cause);
+        assertTrue("cause exception is remembered", cause.contains("Throwable"));
+
         session.close();
     }
-    
 
     private TextMessage createTextMessage(Session session, String text) throws JMSException
{
         return session.createTextMessage(text);



Mime
View raw message