Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to confirm delivery of Message to Amazon SQS Queue?

I am using AWS sdk for developing SQS based queue pub-sub.

In the very basic prototype, I am pushing messages concurrently to a queue I have already created. However, how can I be sure that my messages are being pushed to the queue ?

What is the guarantee that the messages pushed won't fail in the process, for whatever reason ?

Amazon API query provides for ResponseMetadata which has the RequestID associated with that particular send message request. Is getting that enough to surely confirm the pushing of message to the Queue ?

String requestId = sqs.sendMessage(request).getSdkResponseMetadata().getRequestId();

Does the Amazon sendmessage request not give a response body with Http Code ?

like image 792
The-Proton-Resurgence Avatar asked Sep 26 '16 09:09

The-Proton-Resurgence


2 Answers

See SendMessageResult. There's a getMessageId() that should give you the message-id that was assigned to the message by SQS. If you get that, the message most certainly was delivered. The consumer of the message has access to this same ID when a message is received, and the ID is designed to be globally unique for an extended period of time.

like image 113
Michael - sqlbot Avatar answered Oct 30 '22 07:10

Michael - sqlbot


AWS SendMessageRequest does send status code for each request for pushing messages which is being sent.

int statusCode =     sendMessageResult.getSdkHttpMetadata().getHttpStatusCode();

But this will fail for batch of messages being pushed as we will not know which ones in the batch has not been pushed successfully.

like image 45
The-Proton-Resurgence Avatar answered Oct 30 '22 06:10

The-Proton-Resurgence