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 da4b1d16b2..61a24d44c1 100755 --- a/activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java +++ b/activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java @@ -1207,7 +1207,8 @@ public class ActiveMQMessageConsumer implements MessageAvailableConsumer, StatsC MessageAck ack = new MessageAck(lastMd, MessageAck.POSION_ACK_TYPE, deliveredMessages.size()); ack.setFirstMessageId(firstMsgId); - ack.setPoisonCause(new Throwable("Exceeded redelivery policy limit:" + redeliveryPolicy)); + ack.setPoisonCause(new Throwable("Exceeded redelivery policy limit:" + redeliveryPolicy + + ", cause:" + lastMd.getRollbackCause(), lastMd.getRollbackCause())); session.sendAck(ack,true); // Adjust the window size. additionalWindowSize = Math.max(0, additionalWindowSize - deliveredMessages.size()); 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 798cb2ac6b..0fb9728aa5 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 @@ -327,8 +327,13 @@ public class MessageListenerRedeliveryTest extends TestCase { message = dlqMessage[0]; assertNotNull("dlq message captured", message); String cause = message.getStringProperty(ActiveMQMessage.DLQ_DELIVERY_FAILURE_CAUSE_PROPERTY); + LOG.info("DLQ'd message cause reported as: {}", cause); + + assertTrue("cause 'cause' exception is remembered", cause.contains("RuntimeException")); + assertTrue("is correct exception", cause.contains(getName())); assertTrue("cause exception is remembered", cause.contains("Throwable")); + assertTrue("cause policy is remembered", cause.contains("RedeliveryPolicy")); session.close(); }