My application sends messages to a AWS SQS queue for jobs that need some sort of background processing. My processing daemon receives and processes the messages like this:
$result = $sqsClient->receiveMessage([
'QueueUrl' => \Myapp\Config::get('sqs.queue'),
'WaitTimeSeconds' => 20,
'MaxNumberOfMessages' => 1
]);
if (isset($result['Messages'])) {
foreach ($result->getPath('Messages/*/Body') as $messageBody) {
$handler = new \Myapp\Handler();
$handler->dispatch($messageBody);
}
}
This works fine, however I can see from the SQS console that the messages that my script retrieves are put into the "Messages in Flight" category, and then after a while they're put back into "Messages Available", and my script ends up picking them up again.
How can I remove the messages from the SQS queue, or even better mark them as completed?