【问题标题】:SQS: AWS.SimpleQueueService.UnsupportedOperation: Message attribute list values in SendMessage operation are not supportedSQS:AWS.SimpleQueueService.UnsupportedOperation:不支持 SendMessage 操作中的消息属性列表值
【发布时间】:2021-09-26 16:29:54
【问题描述】:

我正在使用 aws-sdk-js 将消息发送到 AWS 中的标准队列。下面是payload,

{
  MessageBody: 'UUID',
  QueueUrl: 'https://sqs.eu-west-1.amazonaws.com/<account>/<queue-name>',
  DelaySeconds: 0,
  MessageAttributes: {
    attribute1: {
      StringValue: 'UUID',
      StringListValues: [],
      BinaryListValues: [],
      DataType: 'String'
    },
    attribute2: {
      StringValue: 'SQS',
      StringListValues: [],
      BinaryListValues: [],
      DataType: 'String'
    },
    attribute3: {
      StringValue: 'UUID',
      StringListValues: [],
      BinaryListValues: [],
      DataType: 'String'
    }
  }
}

代码片段,

const AWS = require('aws-sdk');

const sqs = new AWS.SQS();
const params = { /* the above object */ }
sqs.sendMessage(params).promise();

但是我收到了这个错误,

AWS.SimpleQueueService.UnsupportedOperation: Message attribute list values in SendMessage operation are not supported.

什么是错误?我需要对有效负载进行字符串化吗?

【问题讨论】:

  • @404 更新了问题

标签: amazon-web-services aws-sdk amazon-sqs aws-sdk-js


【解决方案1】:

您还没有给出生成消息的代码,很难说出不支持的值是如何进入有效负载的。

但是,消息属性值没有“列表”数据类型。 aws docs。唯一支持的数据类型是

  • 字符串
  • 号码
  • 二进制
  • 自定义(使用上述方法之一创建自定义字段,例如 Number.EmployeeId)

java example from aws docs

在您的消息负载中,以下两个字段值是列表数据类型

  StringListValues: [],
  BinaryListValues: [],

你应该删除它们。

【讨论】:

    猜你喜欢
    • 2020-07-27
    • 1970-01-01
    • 2021-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多