feat(sqs): allow requesting MessageAttributes on ReceiveMessage (interop-only) #1659
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Enable opt-in retrieval of Amazon SQS user-defined message attributes on receive, without changing default mappers. By design, this PR is interop-only: attributes are requested from SQS when configured, and are available to custom
ISqsEnvelopeMapperimplementations. Built-in mappers remain unchanged.Motivation
Amazon SQS only returns user-defined message attributes when explicitly requested (
ReceiveMessageRequest.MessageAttributeNames). The transport currently never sets this field, so consumers cannot read those attributes. This PR forwards configured names to the receive request to support interoperability scenarios that rely on custom mappers.What changed
AmazonSqsQueue.MessageAttributeNames(optional).ConfigureRequest, applyMessageAttributeNamesonly when the list is non-empty.RawJsonSqsEnvelopeMapperorDefaultSqsEnvelopeMapper.How to use
Note
The mapping of attributes received for the
Envelope(headers/metadata) is handled by your customISqsEnvelopeMapper.Notes
MessageAttributeNamesisnullor empty, no attributes are requested (current default)."All"requests all user-defined message attributes.ReceiveMessageRequest.MessageAttributeNames); sending attributes remains unchanged and is handled by the SQS envelope mapper."All") can increase the response payload size; use only when needed.ReceiveMessageRequest.MessageSystemAttributeNames) are out of scope for this change.Tests
configure_requestdefault_message_attribute_names_is_null_on_endpointconfigure_request_does_not_set_message_attribute_names_when_nullconfigure_request_does_not_set_when_empty_listBackward compatibility
No breaking changes. If not configured, behavior is identical to current versions.
Documentation
Short note in the SQS transport docs explaining
MessageAttributeNamesand the "All" keyword.AWS Documentation