Blankman
Blankman

Reputation: 267270

Is it possible to know if a message was received before?

When looking at the properties of a SQS message, do any of the message properties indicated if this message has been received before?

I can see that the message has the properties:

  1. messageid
  2. receipthandle
  3. md5ofBody
  4. body
  5. a list of key/value attributes

From the above I guess it doesn't expose the number of retries? Because I know there is a setting where you can force the message to go to 'dead letters' if it is retried too many times.

Upvotes: 1

Views: 1213

Answers (1)

hellomichibye
hellomichibye

Reputation: 4302

There is a ApproximateReceiveCount and ApproximateFirstReceiveTimestamp attribute that you can use.

Using the Java SDK you can access the attributes with the Map<String,String> getAttributes() method on the Message object. E.g. message.getAttributes().get("ApproximateReceiveCount")

http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/sqs/model/Message.html#getAttributes--

Upvotes: 4

Related Questions