📢 Registration + agenda now live
Explore the latest Grafana Cloud and AI solutions, learn tips & tricks from demos and hands-on workshops, and get actionable advice to advance your observability strategy. Register now and get 50% off - limited tickets available (while they last!).
Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.
SQSClient.deleteMessage(queueUrl, receiptHandle) deletes a message from the specified Amazon Simple Queue Service (SQS) queue.
Parameters
Name
Type
Description
queueUrl
string
The URL of the Amazon SQS queue from which messages are deleted. Queue URLs and names are case-sensitive.
receiptHandle
string
The receipt handle associated with the message to delete. The receipt handle is returned when you receive a message using receiveMessages.
Returns
Type
Description
Promise
A Promise that fulfills when the message is successfully deleted.
Example
JavaScript
import exec from'k6/execution';import{
AWSConfig,
SQSClient,}from'https://jslib.k6.io/aws/0.14.0/sqs.js';const awsConfig =newAWSConfig({region: __ENV.AWS_REGION,accessKeyId: __ENV.AWS_ACCESS_KEY_ID,secretAccessKey: __ENV.AWS_SECRET_ACCESS_KEY,sessionToken: __ENV.AWS_SESSION_TOKEN,});const sqs =newSQSClient(awsConfig);const testQueue ='https://sqs.us-east-1.amazonaws.com/000000000/test-queue';exportdefaultasyncfunction(){// If our test queue does not exist, abort the execution.const queuesResponse =await sqs.listQueues();if(queuesResponse.urls.filter((q)=> q === testQueue).length ==0){
exec.test.abort();}// Send a message to the queueawait sqs.sendMessage(testQueue,JSON.stringify({value:'123'}));// Receive messages from the queueconst messages =await sqs.receiveMessages(testQueue);// Delete each received messagefor(const message of messages){
console.log('Deleting message:', message.messageId);await sqs.deleteMessage(testQueue, message.receiptHandle);}}