Not receiving Message Attributes when calling ReceiveMessage or on aws cli

0
  1. SNS Topic with "Enable Raw Message Delivery" enabled.
  2. Pre-created SQS resource with the (I think) correct policy.
  3. Pre-created SNS topic with the (I think) correct policy.
  4. Pre-created subscription with SQS/SNS with the (I think) correct policy.

My Golang service publishes to SNS topic with one Message Attribute OR use web client to publish to SNS topic with the same Message Attribute. Either way, the end result is the same. Service code (Golang) contains the following block for receiving messages: var ( all = "All" ) output, err := c.sqs.ReceiveMessage(&sqs.ReceiveMessageInput{ QueueUrl: &c.QueueURL, MaxNumberOfMessages: &maxMessages, AttributeNames: []*string{aws.String(sqs.MessageSystemAttributeNameApproximateFirstReceiveTimestamp)}, MessageAttributeNames: []*string{&all}, })

If I receive messages on AWS SQS web page then review each message on the web page, I see the Message Attributes on each message. However, if I run my Golang application, the MessageAttributes is always nil. I see the "regular" Attributes but not the Message Attributes. Next, I tried aws sqs receive-message --queue-url https://sqs.us-east-1.amazonaws.com/my-queue-url --attribute-name SenderId SentTimestamp --message-attribute-name ALL --max-number-of-messages 2. This too DID NOT have Message Attributes. In both cases, the rest of the data is correct.

What would exclude the aws cli and my service from receiving the Message Attributes?

1 Answer
0

Regarding the CLI, I've managed to successfully retreive message attributes using "All" but not "ALL" so that's the first thing.

Secondly I could only do it with "--attribute-name All"; any attempt with SenderId etc refused to return attributes. I looked at the documentation for ALI and also the AWS API and found attribute-name vs message-attribute-name confusing and poorly documented. The API doc https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_ReceiveMessage.html even says attribute-name is for backward-compatibility only, but I found no way to get attributes without specifying it.

EXPERT
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions