I am currently using amazon's SQS, and am having issues when trying to delete queue messages that are currently "In Flight".
Below is some example code:
ReceiveMessageRequest queueRequest = new ReceiveMessageRequest();
queueRequest.WithMaxNumberOfMessages(1);
queueRequest.WithQueueUrl(config.QueueURL);
queueRequest.WithAttributeName("All");
ReceiveMessageResponse response = sqs.ReceiveMessage(queueRequest);
if (response.IsSetReceiveMessageResult())
{
ReceiveMessageResult result = response.ReceiveMessageResult;
if (result.IsSetMessage())
{
if (result.Message.First() != null)
{
return new Tuple<string, string, bool>(result.Message.First().ReceiptHandle, result.Message.First().Body ?? null, false);
}
}
}
Now after receiving both the Handle, and the message body, I store the Receipt handle string into cloud storage (DynamoDB for example). I then later on load that handle out of the storage service, and call a delete with something similar to the following:
sqs.DeleteMessage(new DeleteMessageRequest() { QueueUrl = "urL", ReceiptHandle = handle });
However, when running that line, I receive a "The input receipt handle is invalid" error message.
Note, I know that this message has not gotten re-received, so the receipt handle being logged, should be the most recent one. Also note that I can currently delete messages within that same application, simply by sleeping after the message is received, and then trying to delete it as above!
Any ideas?