Skip to content

Make Management.queuePurge(String queue) to return the number of purged messages #151

Closed
@artembilan

Description

@artembilan

Is your feature request related to a problem? Please describe.

In fact the implementation is like this:

  @Override
  public void queuePurge(String queue) {
    Map<String, Object> responseBody = delete(queueLocation(queue) + "/messages", CODE_200);
    if (!responseBody.containsKey("message_count")) {
      throw new AmqpException("Response body should contain message_count");
    }
  }

So, we really have access to that count.

A reason for the request that in Spring we have a contract in the AmqpAdmin like:

	/**
	 * Purges the contents of the given queue.
	 * @param queueName the name of the queue.
	 * @return the number of messages purged.
	 * @since 2.1
	 */
	int purgeQueue(String queueName);

Thanks

Describe the solution you'd like

Pretty simple:

int queuePurge(String queue);

and therefore:

  @Override
  public int queuePurge(String queue) {
    Map<String, Object> responseBody = delete(queueLocation(queue) + "/messages", CODE_200);
    if (!responseBody.containsKey("message_count")) {
      throw new AmqpException("Response body should contain message_count");
    }
    return Integer.parseInt(responseBody.get("message_count").toString());
  }

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions