Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .autover/changes/45a6ab22-5bb9-4b65-bfb1-94571b502622.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"Projects": [
{
"Name": "AWS.Messaging",
"Type": "Patch",
"ChangelogMessages": [
"Add SentTimestamp to SQSMetadata"
]
}
]
}
5 changes: 5 additions & 0 deletions src/AWS.Messaging/SQSMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ public class SQSMetadata
/// </summary>
public string? MessageGroupId { get; set; }

/// <summary>
/// The time at which the message was sent to the queue (epoch time in milliseconds).
/// </summary>
public string? SentTimestamp { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the 'long' timestamp a string? Is it stored in the json itself as a quoted string? Even if so, is there any possibility to have non-numerical value?

Copy link
Author

@burhansavci burhansavci Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept it as a string? for three main reasons:

  • The AWS SQS API itself returns this value as a string within the JSON payload, as documented in here.
  • The underlying data structure for all SQS message attributes is a Dictionary<string, string>, so it's read as a string by default.
  • I'm accustomed to converting this into a long myself, then into DateTimeOffset if needed, when I directly use the Message class. It might be best to maintain the same behavior.

However, I agree that converting it to a long in the SQSMetadata class is more appropriate, as there's no indication in the documents that it could be anything else. I can update my PR if that's fine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not one to decide, I just stumbled on that since it looks quite suspicious :-)
(and I might have to propagate it correctly in my serializers PR if your goes first, hence the questions)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it.😄 In that case, let's wait for the team's decision.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@normj any preference on which one makes more sense?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. I do agree this is a useful to add.

For the better user experience I think this library should do the conversion to DateTime from the epoch. It is only a string in the SDK because the timestamp is being given in the generic message attribute class. One of the goals of this library is to make the experience working with SQS more .NET idiomatic then the generated SQS client.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@normj, any particular reason for DateTime instead of DateTimeOffset here?


/// <summary>
/// Each message attribute consists of a Name, Type, and Value.For more information, see Amazon SQS message attributes (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-message-metadata.html#sqs-message-attributes)
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public static SQSMetadata CreateSQSMetadata(Message message)
{
metadata.MessageGroupId = JsonPropertyHelper.GetAttributeValue(message.Attributes, "MessageGroupId");
metadata.MessageDeduplicationId = JsonPropertyHelper.GetAttributeValue(message.Attributes, "MessageDeduplicationId");
metadata.SentTimestamp = JsonPropertyHelper.GetAttributeValue(message.Attributes, "SentTimestamp");
}

return metadata;
Expand Down