Skip to content

Message attributes during message publish to SQS not populated in SQS, even when the SDK reports success #531

@dallin-defimono

Description

@dallin-defimono

Describe the bug

When publishing a message to a queue with custom message attributes, an md5 checksum is returns via the publish result indicating content was submitted and the result returns Ok indicating successful message publish.

On retrieval and when specifying all attributes to read, no attributes are returned and they are dropped.

Expected Behavior

I would hope/expect that when a message is published with message attributes, that on successful publish the md5 checksum is populated if there are actual attributes and set to None when none are provided, similar to the read.

The inverse is I would expect the read when specifying all attributes would retrieve those custom attributes I had set.

Current Behavior

Here is a successful message publish.

2022-05-12 07:14:53,861 INFO  [limit_order_book_library::message] SendMessageBatchOutput {
    successful: Some(
        [
            SendMessageBatchResultEntry {
                id: Some(
                    "0",
                ),
                message_id: Some(
                    "99d2f2ca-bd1d-4cbb-8535-5d7b3e066298",
                ),
                md5_of_message_body: Some(
                    "010284b4142be514e2ea60b37f332abe",
                ),
                md5_of_message_attributes: Some(
                    "f05254252ef1319d1b7b1adeb798d363",
                ),
                md5_of_message_system_attributes: None,
                sequence_number: Some(
                    "18869743035370223616",
                ),
            },
        ],
    ),
    failed: None,
}

Notice the md5 of message attributes are correctly set to the hash vs None for the system sttributes.

When read back from the queue, the message attributes are none.

        [
            Message {
                message_id: Some(
                    "1836cc41-ac3c-448d-9466-5d92f730e41c",
                ),
                receipt_handle: Some(
                    "AQEBJdxoLP1T39+U94YGdQXlOD3kLXZWMLtY9cKNmaWXUkpjTUaxMXUyp9VPVjAB/kzfmdXrGIun+3yLFlUn5TAvrjf14Xl0Fy2OsVLIf2/dFS3WsVE8hofv4xZro6D+uRloRsbbjYzOaJW7Ar5keLonrke9jAITlVnrEBtCWYxGUeKqOQ0/xZxWpIzat44ZetZ3NZbZAhtRRip6mWUNUFnTQyt8qLJqDrjRrdYpjJWcTNCY5pp4PX9tgi3KzCC5lM2xlzzR8jsucvxuKjASEwUJTj3SC3R5u/0tOqJjxwIV4bY=",
                ),
                md5_of_body: Some(
                    "898ad19eb6a102a210923ed3d66a2d57",
                ),
                body: Some(
                    "some random message"
                ),
                attributes: Some(
                    {
                        SentTimestamp: "1652339693855",
                        SequenceNumber: "18869743035336431616",
                        MessageDeduplicationId: "f5b2c1477bcb2e73d43b87fedcbb42b4c25725e36193c813a401d882581c2ec8",
                        MessageGroupId: "orders",
                        SenderId: "AROAYMSU6Y6F4MWW4T6VG:[email protected]",
                        ApproximateFirstReceiveTimestamp: "1652339717879",
                        ApproximateReceiveCount: "1",
                    },
                ),
                md5_of_message_attributes: None,
                message_attributes: None,
            },
        ],
    ),
}

The code to set the attributes is currently this.

    let action_message_attribute = MessageAttributeValue::builder()
        .set_data_type(Some("String".to_string()))
        .set_string_value(Some("Create".to_string()))
        .build();

    let publish_result = app_state.app_config.sqs_client
        .send_message()
        .queue_url(app_state.app_config.limit_order_book_intake_url.clone())
        .message_body("hello from my queue")
        .message_group_id("MyGroup")
        .message_attributes("action", action_message_attribute)
        .send()
        .await;

    let queue_attribute_name: Vec<QueueAttributeName> = vec![QueueAttributeName::All];

    let receive_message = app_state.app_config.sqs_client
        .receive_message()
        .set_attribute_names(Some(queue_attribute_name))
        .queue_url(app_state.app_config.limit_order_book_intake_url.clone())
        .send()
        .await;

    match publish_result {
        Ok(response) => {
            log::debug!("Publish completed");
            log::debug!("{:#?}", response)
        }
        Err(error) => {
            log::error!("{:#?}", error);
        }
    }

    match receive_message {
        Ok(response) => {
            log::debug!("Receive completed");
            log::debug!("{:#?}", response)
        }
        Err(error) => {
            log::error!("{:#?}", error);
        }
    }

I had to reverse engineer this quite a bit from the SDK source code and docs as this is not really documented how to proceed, but seems that publish works 100% but read does not.

Keep in mind, I am requesting ALL attributes when reading from the queue like so

Reproduction Steps

Send a message with version 0.11.0 of the SDK with custom attributes and then try to read them back. Unless I am missing something it will return success but the actual attributes are never set/returned.

Possible Solution

No response

Additional Information/Context

No response

Version

0.11.0

Environment details (OS name and version, etc.)

Mac OSX 12.3.1

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions