SQS: Support Async JSON SQS Protocol & Message Attributes #2226
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.
@auvipy 👋 Hi there! There is no ticket for this issue -- I found this bug myself and thought I'd fix it.
Adds support for consuming botocore SQS
json
models in the SQS async code. This only affects consumer code.Several parameters are supplied incorrectly as they have changed in the
query
tojson
botocore change. If you have a newer version of botocore, you will get thejson
service model instead of the oldquery
model. I found several places where kombu was generating calls to the newjson
API (indicated by the x-amz-json-1.0 content-type) but providing parameter names consistent with thequery
protocol.This PR makes kombu aware of both the
json
andquery
protocol query names and provide them both. When the AWS request is later constructed from the service model, we apply protocol-specific and common parameters. Unfortunately, AWS has not maintained consistency in the parameter names, so I manually reviewed each API call and supplied both.The only things that broke were compound data types for ReceiveMessage -- those are attribute names. Other things did not break because the code path for post-process message deletion is through the synchronous branch, which uses standard boto and not the async request builder (
kombu.transport.SQS.Channel.basic_ack
). Nevertheless, I fixed all the parameters in the async client.Logged request after PR (note new usage of
AttributeNames
instead ofAttributeName.1
):This code supporting both protocols can be cleaned up if Kombu is willing to require
botocore>=1.34.90
, which was released in April 2024 (boto/botocore/pull/3165). It can take quite a while to move forward the boto3/botocore/moto ecosystem, so Kombu may want to give consumers some time before dropping old botocores. Either way, this PR would be required.As I fixed this to get support for AttributeNames back, I also added support for customizing fetched attributes via
transport_options.fetch_message_attributes
. Now you can supply["All"]
to get better diagnostics from SQS. I added documentation for this.