Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARTEMIS-3082 fix non-destructive + rollback #469

Merged
merged 1 commit into from
Apr 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3919,10 +3919,14 @@ void postRollback(final LinkedList<MessageReference> refs, boolean sorted) {

return;
}
if (sorted) {
addSorted(refs, false);
} else {
addHead(refs, false);

// if the queue is non-destructive then any ack is ignored so no need to add messages back onto the queue
if (!isNonDestructive()) {
if (sorted) {
addSorted(refs, false);
} else {
addHead(refs, false);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,30 @@ public void testNonDestructiveLVQTombstone(ConnectionSupplier producerConnection

}

@Test
public void testMessageCount() throws Exception {
sendMessage(CoreConnection, NON_DESTRUCTIVE_QUEUE_NAME);

QueueBinding queueBinding = (QueueBinding) server.getPostOffice().getBinding(SimpleString.toSimpleString(NON_DESTRUCTIVE_QUEUE_NAME));
assertEquals("Ensure Message count", 1, queueBinding.getQueue().getMessageCount());

//Consume Once
receive(CoreConnection, NON_DESTRUCTIVE_QUEUE_NAME);
assertEquals("Ensure Message count", 1, queueBinding.getQueue().getMessageCount());

sendMessage(CoreConnection, NON_DESTRUCTIVE_QUEUE_NAME);
assertEquals("Ensure Message count", 2, queueBinding.getQueue().getMessageCount());

//Consume Again as should be non-destructive
receive(CoreConnection, NON_DESTRUCTIVE_QUEUE_NAME);
assertEquals("Ensure Message count", 2, queueBinding.getQueue().getMessageCount());

QueueControl control = (QueueControl) server.getManagementService().getResource(ResourceNames.QUEUE + NON_DESTRUCTIVE_QUEUE_NAME);
control.removeAllMessages();

assertEquals("Message count after clearing queue via queue control should be 0", 0, queueBinding.getQueue().getMessageCount());
}


private void receive(ConnectionSupplier consumerConnectionSupplier, String queueName, int i) throws JMSException {
try (Connection consumerConnection = consumerConnectionSupplier.createConnection()) {
Expand Down