javaamazon-web-servicesamazon-sqsaws-sdk-java-2.0

Amazon SQS Do I need to make DeleteMessage request to eliminate message or does some other way exist to delete the message from the queue?


I am new to AWS and wanted to ask a question about Amazon SQS and AWS SDK. From my understanding SQS has visibility timeout feature and after making ReceiveMessage request call the message gets hidden and can not be received for some indicated time.

But what if I want to delete the message from the queue after it gets processed by consumer application ? Do I need to make DeleteMessage request or does some other method exist that I am not aware of, because from what I understand SQS is billed by amount of requests so I would need to pay both for ReceiveMessage and DeleteMessage requests to consume and process the message ?


Solution

  • You have to make a DeleteMessage request. There's no other way for SQS to know you successfully processed the message. The only real alternative is if you are running your code on AWS Lambda with the SQS event trigger integration, at which point Lambda just makes those SQS API calls for you.


    From the SQS pricing page:

    API Actions | Every Amazon SQS action counts as a request.

    So yes, you do apparently pay for every request, after you've used the first 1 million free requests you get each month.