Skip to content

SentTimestamp & ApproximateFirstReceiveTimestamp for the message not carried over to DLQ #386

@narayar

Description

@narayar

The SentTimestamp & ApproximateFirstReceiveTimestamp are not carried over from one SQS to its dead letter queue (DLQ)

We have a scenario in our app where we depend on original SentTimestamp and this came out when I was running my tests using this lib instead of real AWS SQS.

Flow:
Create 2 queues:

  • Primary
  • PrimaryDLQ (this is the dead letter queue (DLQ) for the above Primary queue)
    Set the RedrivePolicy on Primary with maxReceiveCount=2

After receiving the message twice from the Primary queue, the message is moved to PrimaryDLQ, however, this elasticmq is not carrying over the original SentTimestamp & ApproximateFirstReceiveTimestamp which was set when the message came to the Primary queue. It added the timestamp on which the message came to the PrimaryDLQ queue.

AWS SQS carries the same SentTimestamp & ApproximateFirstReceiveTimestamp from the original message over to DLQ. I tested this on AWS SQS creating 2 SQS and performing the same test as stated above.

AWS SQS -
Message Receive - 1
aws sqs receive-message --queue-url https://sqs.us-east-1.amazonaws.com/*/narayar-local-retry --attribute-names All --message-attribute-names All
{
"Messages": [
{
"Body": "foo bar",
"Attributes": {
"ApproximateFirstReceiveTimestamp": "1599031260287",
"ApproximateReceiveCount": "1",
"SentTimestamp": "1599030599229"
},
"MD5OfBody": "327b6f07435811239bc47e1544353273",
"MessageId": "938bd0cf-15ab-4115-8396-83e48ba17f27"
}
]
}

Message Receive - 2
aws sqs receive-message --queue-url https://sqs.us-east-1.amazonaws.com/*/narayar-local-retry --attribute-names All --message-attribute-names All
{
"Messages": [
{
"Body": "foo bar",
"Attributes": {
"ApproximateFirstReceiveTimestamp": "1599031260287",
"ApproximateReceiveCount": "2",
"SentTimestamp": "1599030599229"
},
"MD5OfBody": "327b6f07435811239bc47e1544353273",
"MessageId": "938bd0cf-15ab-4115-8396-83e48ba17f27"
}
]
}

Message moved to DLQ - Message received from DLQ
aws sqs receive-message --queue-url https://sqs.us-east-1.amazonaws.com/*/narayar-local-dlq --attribute-names All --message-attribute-names All
{
"Messages": [
{
"Body": "foo bar",
"Attributes": {
"ApproximateFirstReceiveTimestamp": "1599031260287",
"ApproximateReceiveCount": "4",
"SentTimestamp": "1599030599229"
},
"MD5OfBody": "327b6f07435811239bc47e1544353273",
"MessageId": "938bd0cf-15ab-4115-8396-83e48ba17f27"
}
]
}

elasticmq -
Message Receive - 1
aws --endpoint-url=http://localhost:9324 sqs receive-message --queue-url http://localhost:9324/queue/WebhooksmsosxRetryQueue --attribute-names All --message-attribute-names All
{
"Messages": [
{
"Body": "Message 111",
"Attributes": {
"ApproximateFirstReceiveTimestamp": "1599031761855",
"SenderId": "127.0.0.1",
"MessageDeduplicationId": "",
"SentTimestamp": "1599031742818",
"ApproximateReceiveCount": "1",
"MessageGroupId": ""
},
"ReceiptHandle": "d1a5ef43-264f-4a68-8253-73999189de44#731d8e04-7093-4c23-a2f8-4da5577079b9",
"MD5OfBody": "f6d67b966ed9d4c93492f3573c9b0d14",
"MessageId": "d1a5ef43-264f-4a68-8253-73999189de44"
}
]
}

Message Receive - 2
aws --endpoint-url=http://localhost:9324 sqs receive-message --queue-url http://localhost:9324/queue/WebhooksmsosxRetryQueue --attribute-names All --message-attribute-names All
{
"Messages": [
{
"Body": "Message 111",
"Attributes": {
"ApproximateFirstReceiveTimestamp": "1599031761855",
"SenderId": "127.0.0.1",
"MessageDeduplicationId": "",
"SentTimestamp": "1599031742818",
"ApproximateReceiveCount": "2",
"MessageGroupId": ""
},
"ReceiptHandle": "d1a5ef43-264f-4a68-8253-73999189de44#a3f71654-e6f4-4522-9d3a-1af51a9bc491",
"MD5OfBody": "f6d67b966ed9d4c93492f3573c9b0d14",
"MessageId": "d1a5ef43-264f-4a68-8253-73999189de44"
}
]
}

Message moved to DLQ - Message received from DLQ
aws --endpoint-url=http://localhost:9324 sqs receive-message --queue-url http://localhost:9324/queue/WebhooksmsosxDLQ --attribute-names All --message-attribute-names All
{
"Messages": [
{
"Body": "Message 111",
"Attributes": {
"ApproximateFirstReceiveTimestamp": "1599031846325",
"SenderId": "127.0.0.1",
"MessageDeduplicationId": "",
"SentTimestamp": "1599031833907",
"ApproximateReceiveCount": "1",
"MessageGroupId": ""
},
"ReceiptHandle": "d1a5ef43-264f-4a68-8253-73999189de44#01afda03-68f0-4ceb-86b3-ba41723687b1",
"MD5OfBody": "f6d67b966ed9d4c93492f3573c9b0d14",
"MessageId": "d1a5ef43-264f-4a68-8253-73999189de44"
}
]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions