Skip to content

Add SentTimestamp to SQSMetadata #283

@burhansavci

Description

@burhansavci

Describe the feature

The SQSMetadata class doesn't expose all the message system attributes, but only exposes MessageDeduplicationId and MessageGroupId. It would be helpful to expose the SentTimestamp message system attribute in SQSMetadata as well. This attribute is currently not exposed, even when a ReceiveMessageRequest is configured with MessageSystemAttributeNames = new List<string> { "All" } in the SQSMessagePoller.

Use Case

I need to access the SentTimestamp attribute to monitor the latency of messages sent by a third-party publisher. This helps me track any delays in delivery to the queue. I have an alarm that triggers and notifies me when this latency exceeds a defined threshold.

Proposed Solution

Expose the SentTimestamp attribute in the SQSMetadata class by adding a new property.

public class SQSMetadata
{
    // other props

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

    // other props
}

And update CreateSQSMetadata in the MessageMetadataHandler class.

internal static class MessageMetadataHandler
{
    public static SQSMetadata CreateSQSMetadata(Message message)
    {
        var metadata = new SQSMetadata
        {
            MessageID = message.MessageId,
            ReceiptHandle = message.ReceiptHandle,
            MessageAttributes = message.MessageAttributes,
        };

        if (message.Attributes != null)
        {
            metadata.MessageGroupId = JsonPropertyHelper.GetAttributeValue(message.Attributes, "MessageGroupId");
            metadata.MessageDeduplicationId = JsonPropertyHelper.GetAttributeValue(message.Attributes, "MessageDeduplicationId");
            metadata.SentTimestamp = JsonPropertyHelper.GetAttributeValue(message.Attributes, "SentTimestamp");
        }

        return metadata;
    }

// other methods..
}

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

AWS.Messaging (or related) package versions

AWS.Messaging 1.0.1

Targeted .NET Platform

.NET 8

Operating System and version

Ubuntu

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestA feature should be added or improved.p2This is a standard priority issuepr/needs-review

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions