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

- **ID:** `aws/sqs-message-retention-period-exceeded`
- **领域:** aws
- **类别:** config_error
- **错误码:** `InvalidParameterValue`
- **验证级别:** ai_generated
- **修复率:** 92%

## 根因

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

## 版本兼容性

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

## 解决方案

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 天）。
   ```

## 无效尝试

- **** — 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. (30% 失败率)
- **** — Trying to set the retention period via the console without refreshing the queue attributes might use a cached, invalid value from a previous configuration. (20% 失败率)
