diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java b/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java index 15075cdc58..5959b6e65a 100755 --- a/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java @@ -1109,12 +1109,12 @@ public class Queue extends BaseDestination implements Task { MessageReference node = messages.next(); node.incrementReferenceCount(); messages.remove(); + QueueMessageReference ref = createMessageReference(node.getMessage()); if (!broker.isExpired(node)) { - QueueMessageReference ref = createMessageReference(node.getMessage()); result.add(ref); count++; } else { - messageExpired(createConnectionContext(), node); + messageExpired(createConnectionContext(), ref); } } } finally {