Skip to content

[#1842] [AMQ-9858] Support purging the first number of messages from a queue#1662

Open
mattrpav wants to merge 1 commit intoapache:mainfrom
mattrpav:AMQ-9858
Open

[#1842] [AMQ-9858] Support purging the first number of messages from a queue#1662
mattrpav wants to merge 1 commit intoapache:mainfrom
mattrpav:AMQ-9858

Conversation

@mattrpav
Copy link
Copy Markdown
Contributor

@mattrpav mattrpav commented Feb 11, 2026

ref: [#1842]
ref: [AMQ-9858]

@mattrpav mattrpav self-assigned this Feb 11, 2026
@mattrpav mattrpav marked this pull request as draft February 19, 2026 15:49
@mattrpav mattrpav marked this pull request as ready for review March 26, 2026 15:42
@mattrpav mattrpav changed the title WIP: [AMQ-9858] Support purging the first number of messages from a queue [AMQ-9858] Support purging the first number of messages from a queue Mar 26, 2026
@mattrpav mattrpav changed the title [AMQ-9858] Support purging the first number of messages from a queue [#1842] [AMQ-9858] Support purging the first number of messages from a queue Mar 26, 2026
@mattrpav mattrpav requested a review from jbonofre March 26, 2026 18:50
* @throws Exception
*/
@MBeanInfo("Removes the first number of messages in the queue.")
void purge(long number) throws Exception;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: for the reader, we could have use numberOfMessages here (to be consistent with QueueView interface).

}

public void purge(long numberOfMessages) throws Exception {
ConnectionContext c = createConnectionContext();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add numberOfMessages validation here:

Suggested change
ConnectionContext c = createConnectionContext();
if (numberOfMessages <= 0) {
return;
}
ConnectionContext c = createConnectionContext();

Else, it means that this method will acquire sendLock, create ConnectionContext and go in the loop even if the number of messages to purge is invalid.


long purgeCount = 0L;
try {
long originalMessageCount = this.destinationStatistics.getMessages().getCount();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the change, originalMessageCount is not used anymore, it can be removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants