【问题标题】:Missing MessageAttributes property in SQS message receiverSQS 消息接收器中缺少 MessageAttributes 属性
【发布时间】:2019-07-23 22:55:31
【问题描述】:

我看到的只是这种类型的数据:

    {
      MessageId: 'c604c772-8468-4cd2-8f3e-9b430ed52d92',
      ReceiptHandle: 'AQEBHyPYuNqFztvy9QNOHeLQg==',
      MD5OfBody: '096c6509c8628bde267adde2b105f4e4',
      Body: 'foobar'
    }

当我进行此调用以从队列中读取时:

const conf = {
  QueueUrl: 'https://sqs.us-west-2.amazonaws.com/920371/logging-q',
  WaitTimeSeconds: 19,  // max is 20 (off by one errors avoided!)
  MaxNumberOfMessages: 9  // max is 10 (off by one errors avoided!)
};

sqs.receiveMessage(conf, cb);

但我在将消息放入队列时添加了 MessageAttributes:

sqs.sendMessageBatch({QueueUrl,Entries: v}, cb);

Entries 是一个数组:

{
    Id: uuid.v4(),
    MessageBody: 'foobar',
    MessageAttributes: {

      logStream: {
        StringValue: LOG_STREAM,
        DataType: 'String'
      },

      logGroup: {
        StringValue: LOG_GROUP,
        DataType: 'String'
      }
    }
  }

有人知道为什么当我从队列中读取时 MessageAttributes 没有出现,即使它们可能被推送到队列中?

【问题讨论】:

    标签: amazon-web-services amazon-sqs


    【解决方案1】:

    在您的receiveMessage 配置文件中,您需要包含MessageAttributeNames 并为其提供属性名称列表或All。看起来您正在使用 javascript,因此您需要查看 receiveMessage https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SQS.html#receiveMessage-property 的 Javascript SDK 文档

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-09-26
      • 1970-01-01
      • 1970-01-01
      • 2020-10-31
      • 2018-03-06
      • 2014-11-10
      • 1970-01-01
      • 2020-03-04
      相关资源
      最近更新 更多