diff --git a/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java b/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java index b38b6e5cc4..ab7c5989a5 100755 --- a/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java +++ b/activemq-core/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java @@ -837,9 +837,7 @@ public class ActiveMQMessageConsumer implements MessageAvailableConsumer, StatsC deliveredCounter++; if ((0.5 * info.getPrefetchSize()) <= (deliveredCounter - additionalWindowSize)) { MessageAck ack = new MessageAck(md, ackType, deliveredCounter); - if( deliveredMessages.isEmpty() ) { - ack.setFirstMessageId(ack.getLastMessageId()); - } else { + if( !deliveredMessages.isEmpty() ) { ack.setFirstMessageId(deliveredMessages.getLast().getMessage().getMessageId()); } ack.setTransactionId(session.getTransactionContext().getTransactionId());