feat(sqs): allow requesting MessageAttributes on ReceiveMessage (interop-only)#1659
Conversation
|
👍 |
|
To what end? How is this useful at all? And the configuration for this isn't readily discoverable at all from the configuration right now. |
|
Thanks for the quick feedback. In our environment some upstream producers (non-Wolverine) put business metadata in SQS message attributes (e.g., correlationId, tenantId). SQS only returns those if requested on receive, so this PR adds a strictly opt-in switch to pass MessageAttributeNames. Defaults stay the same and nothing changes unless configured. This is intentionally the smallest viable change to keep the transport aligned with AWS-native behavior while unblocking interop. I intentionally kept the scope minimal. I’m happy to adjust the code (API shape/naming/placement) to match Wolverine’s conventions and make it more discoverable. What would you suggest here? |
|
@MurilloFagundes What I'd mostly say is that this does no real harm, but no real good unless you know it's there. Happy to take this in, but I might ask you to send a later update to the SQS docs about the usage and maybe even a little background about why you did this. No hurry though. I'll have this out in 4.11 though. |
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