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개 답변
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.

전문가
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠