InvalidParameterValue aws config_error ai_generated true

调用 SendMessage 操作时发生错误 (InvalidParameterValue):参数 MessageRetentionPeriod 的值无效。必须在 60 到 1209600 秒之间

An error occurred (InvalidParameterValue) when calling the SendMessage operation: Value for parameter MessageRetentionPeriod is not valid. Must be between 60 and 1209600 seconds

ID: aws/sqs-message-retention-period-exceeded

其他格式: JSON · Markdown 中文 · English
92%修复率
88%置信度
1证据数
2023-09-12首次发现

版本兼容性

版本状态引入弃用备注
Amazon SQS API 2012-11-05 active
AWS SDK for Java 2.20.0 active

根因分析

SQS 队列的消息保留期被设置在允许范围(60 秒到 14 天)之外,导致发送或更新操作失败。

English

The SQS queue's message retention period was set outside the allowed range (60 seconds to 14 days), causing send or update operations to fail.

generic

官方文档

https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_SetQueueAttributes.html

解决方案

  1. 将 MessageRetentionPeriod 设置为 60 到 1209600 秒之间的有效值。例如,使用 AWS CLI:'aws sqs set-queue-attributes --queue-url https://sqs.us-east-1.amazonaws.com/123456789012/MyQueue --attributes MessageRetentionPeriod=345600'(4 天)。
  2. 如果队列是使用无效的保留期创建的,请删除并重新创建具有有效值的队列:'aws sqs create-queue --queue-name MyQueue --attributes MessageRetentionPeriod=86400'(1 天)。

无效尝试

常见但无效的做法:

  1. 30% 失败

    Setting the retention period to exactly 60 seconds or 1209600 seconds may still fail if the queue already exists with a different value; the update might require a queue recreation.

  2. 20% 失败

    Trying to set the retention period via the console without refreshing the queue attributes might use a cached, invalid value from a previous configuration.