diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java index 31a4869510..41f504fa29 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java @@ -2454,7 +2454,12 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { postOffice.route(copyMessage, tx, false, rejectDuplicate); - acknowledge(tx, ref); + if (expiry) { + acknowledge(tx, ref, AckReason.EXPIRED); + } else { + acknowledge(tx, ref); + } + } @SuppressWarnings({"ArrayToString", "ArrayToStringConcatenation"}) diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ExpiryRunnerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ExpiryRunnerTest.java index fa04395ae4..74c9cff8b5 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ExpiryRunnerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ExpiryRunnerTest.java @@ -163,6 +163,7 @@ public class ExpiryRunnerTest extends ActiveMQTestBase { Assert.assertNotNull(cm); // assertEquals("m" + i, cm.getBody().getString()); } + Assert.assertEquals(100, ((Queue) server.getPostOffice().getBinding(qName).getBindable()).getMessagesExpired()); consumer.close(); }