PurgeQueue - Amazon Simple Queue Service
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

PurgeQueue

Deletes available messages in a queue (including in-flight messages) specified by the QueueURL parameter.

Important

When you use the PurgeQueue action, you can't retrieve any messages deleted from a queue.

The message deletion process takes up to 60 seconds. We recommend waiting for 60 seconds regardless of your queue's size.

Messages sent to the queue before you call PurgeQueue might be received but are deleted within the next minute.

Messages sent to the queue after you call PurgeQueue might be deleted while the queue is being purged.

Request Syntax

{ "QueueUrl": "string" }

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

The request accepts the following data in JSON format.

QueueUrl

The URL of the queue from which the PurgeQueue action deletes messages.

Queue URLs and names are case-sensitive.

Type: String

Required: Yes

Response Elements

If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.

Errors

For information about the errors that are common to all actions, see Common Errors.

InvalidAddress

The accountId is invalid.

HTTP Status Code: 400

InvalidSecurity

When the request to a queue is not HTTPS and SigV4.

HTTP Status Code: 400

PurgeQueueInProgress

Indicates that the specified queue previously received a PurgeQueue request within the last 60 seconds (the time it can take to delete the messages in the queue).

HTTP Status Code: 400

QueueDoesNotExist

The specified queue doesn't exist.

HTTP Status Code: 400

RequestThrottled

The request was denied due to request throttling.

  • The rate of requests per second exceeds the Amazon KMS request quota for an account and Region.

  • A burst or sustained high rate of requests to change the state of the same KMS key. This condition is often known as a "hot key."

  • Requests for operations on KMS keys in a Amazon CloudHSM key store might be throttled at a lower-than-expected rate when the Amazon CloudHSM cluster associated with the Amazon CloudHSM key store is processing numerous commands, including those unrelated to the Amazon CloudHSM key store.

HTTP Status Code: 400

UnsupportedOperation

Error code 400. Unsupported operation.

HTTP Status Code: 400

Examples

The following example query request purges a queue named MyQueue. The structure of AUTHPARAMS depends on the signature of the API request. For more information, see Examples of Signed Signature Version 4 Requests in the Amazon General Reference.

Example

Using Amazon JSON protocol (default)

Sample Request

POST / HTTP/1.1 Host: sqs.us-east-1.amazonaws.com X-Amz-Target: AmazonSQS.PurgeQueue X-Amz-Date: <Date> Content-Type: application/x-amz-json-1.0 Authorization: <AuthParams> Content-Length: <PayloadSizeBytes> Connection: Keep-Alive { "QueueUrl": "https://sqs.us-east-1.amazonaws.com/177715257436/MyQueue/" }

Sample Response

HTTP/1.1 200 OK x-amzn-RequestId: <requestId> Content-Length: 0 Date: <Date> Content-Type: application/x-amz-json-1.0

Example

Using Amazon query protocol

Sample Request

POST /177715257436/MyQueue HTTP/1.1 Host: sqs.us-east-1.amazonaws.com Content-Type: application/x-www-form-urlencoded X-Amz-Date: <Date> Authorization: <AuthParams> Content-Length: <PayloadSizeBytes> Connection: Keep-Alive Action=PurgeQueue

Sample Response

HTTP/1.1 200 OK <?xml version="1.0"?> <PurgeQueueResponse xmlns="http://queue.amazonaws.com/doc/2012-11-05/"> <ResponseMetadata> <RequestId>706cb8e1-8799-5ef8-9472-e4914393f2f0</RequestId> </ResponseMetadata> </PurgeQueueResponse>

See Also

For more information about using this API in one of the language-specific Amazon SDKs, see the following: