From adb466b2f8d7e4fb2045804fe48cfd82d710f0d1 Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Thu, 25 Jan 2018 21:17:38 -0500 Subject: [PATCH] ARTEMIS-1638 Fixing Purge rollback behaviour (fix) --- .../artemis/core/server/impl/QueueImpl.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 f6b6e000e9..77adc85faf 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 @@ -2896,11 +2896,26 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { void postRollback(final LinkedList refs) { //if we have purged then ignore adding the messages back if (purgeOnNoConsumers && getConsumerCount() == 0) { + purgeAfterRollback(refs); + return; } addHead(refs, false); } + private void purgeAfterRollback(LinkedList refs) { + try { + Transaction transaction = new TransactionImpl(storageManager); + for (MessageReference reference : refs) { + incDelivering(); // post ack will decrement this, so need to inc + acknowledge(transaction, reference, AckReason.KILLED); + } + transaction.commit(); + } catch (Exception e) { + logger.warn(e.getMessage(), e); + } + } + private long calculateRedeliveryDelay(final AddressSettings addressSettings, final int deliveryCount) { long redeliveryDelay = addressSettings.getRedeliveryDelay(); long maxRedeliveryDelay = addressSettings.getMaxRedeliveryDelay();