可见性超时后 AWS SQS 消息的 "SentTimestamp" 属性是否发生变化?

Does "SentTimestamp" attribute of AWS SQS message change after visibility timeout?

使用 AWS SQS 时,消息的“SentTimestamp”属性在从队列中收到后会发生变化,但不会在 可见性超时 已过期?

不,这种行为是不可取的,因为 SentTimestamp 具体描述了消息首次发送到队列的时间。

这个描述可见性超时的 documentation 提供了一些见解:

Immediately after the component receives the message, the message is still in the queue. However, you don't want other components in the system receiving and processing the message again. Therefore, Amazon SQS blocks them with a visibility timeout, which is a period of time during which Amazon SQS prevents other consuming components from receiving and processing that message.

此处重要的一点是 消息从未真正离开队列 ,它只是对其他正在接收消息的客户端隐藏。所以 MessageID 和 SentTimeout 等消息内容不会改变。另一方面,每次收到消息时,与接收消息相关的事情(如 RecieptHandle 和 Receive Count)都会发生变化。

您可以通过以下方式从 AWS Web 控制台自行验证:

  • 正在队列中创建消息。
  • 正在查看消息。
  • 正在等待可见性超时到期。完成后,在新选项卡中再次打开 SQS 控制台。
  • 正在新标签页中再次查看邮件。比较两个收到的消息的内容。