diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java index 2b5ecaf4f0..c31a32320b 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java @@ -2420,6 +2420,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { long txID = storageManager.generateID(); storageManager.deleteAddressBinding(txID, addressInfo.getId()); storageManager.commitBindings(txID); + pagingManager.deletePageStore(address); } @Override 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 44c5ba4e22..e04cf47f9c 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 @@ -49,6 +49,7 @@ import org.apache.activemq.artemis.api.core.management.CoreNotificationType; import org.apache.activemq.artemis.api.core.management.ManagementHelper; import org.apache.activemq.artemis.core.filter.Filter; import org.apache.activemq.artemis.core.io.IOCallback; +import org.apache.activemq.artemis.core.paging.cursor.PagePosition; import org.apache.activemq.artemis.core.paging.cursor.PageSubscription; import org.apache.activemq.artemis.core.paging.cursor.PagedReference; import org.apache.activemq.artemis.core.persistence.QueueStatus; @@ -2968,6 +2969,7 @@ public class QueueImpl implements Queue { Iterator lastIterator = null; MessageReference cachedNext = null; + HashSet previouslyBrowsed = new HashSet(); private QueueBrowserIterator() { messagesIterator = new SynchronizedIterator(messageReferences.iterator()); @@ -3003,15 +3005,21 @@ public class QueueImpl implements Queue { while (true) { if (messagesIterator != null && messagesIterator.hasNext()) { MessageReference msg = messagesIterator.next(); + if (msg.isPaged()) { + previouslyBrowsed.add(((PagedReference)msg).getPosition()); + } return msg; } else { break; } } if (getPagingIterator() != null) { - if (getPagingIterator().hasNext()) { + while (getPagingIterator().hasNext()) { lastIterator = getPagingIterator(); - MessageReference ref = getPagingIterator().next(); + PagedReference ref = getPagingIterator().next(); + if (previouslyBrowsed.contains(ref.getPosition())) { + continue; + } return ref; } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/TemporaryQueueTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/TemporaryQueueTest.java index 5be1638a83..86b194e612 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/TemporaryQueueTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/TemporaryQueueTest.java @@ -135,12 +135,13 @@ public class TemporaryQueueTest extends SingleServerTestBase { assertTrue(Arrays.asList(storeNames).contains(address)); consumer.close(); + session.deleteQueue(queue); + session.close(); storeNames = server.getPagingManager().getStoreNames(); assertFalse(Arrays.asList(storeNames).contains(address)); - session.close(); } @Test