gpt4 book ai didi

amazon-web-services - SQS 消息接收器中缺少 MessageAttributes 属性

转载 作者:行者123 更新时间:2023-12-02 19:55:31 26 4
gpt4 key购买 nike

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

    {
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);

条目是一个数组:

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

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

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

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

最佳答案

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

关于amazon-web-services - SQS 消息接收器中缺少 MessageAttributes 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57173184/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com