我能否确定Amazon SQS消息是否仍在发送中? [英] Can I tell if an Amazon SQS message is still in flight?

查看:53
本文介绍了我能否确定Amazon SQS消息是否仍在发送中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑到Amazon SQS消息,是否可以通过API判断它是否仍在运行中?还是在收到消息时需要记下时间戳,从当前时间中减去该时间戳,然后检查它是否小于可见性超时?

Given an Amazon SQS message, is there a way to tell if it is still in flight via the API? Or, would I need to note the timestamp when I receive the message, subtract that from the current time, and check if that is less than the visibility timeout?

推荐答案

使用Amazon Simple Queuing Service(SQS)的正常流程是:

The normal flow for using Amazon Simple Queueing Service (SQS) is:

  • 使用 SendMessage 将邮件推送到队列中(它可以在队列中最多保留14天)
  • 应用程序使用 ReceiveMessage 从队列中检索消息(不保证先进先出)
  • 当应用程序完成消息的处理后,它会调用 DeleteMessage (它也可以调用 ChangeMes​​sageVisibility 来延长时间,直到出现以下情况-出)
  • 如果应用程序未在预先配置的时间段内删除消息,则SQS会将消息重新出现在队列上
  • 如果从队列中检索消息的次数超过了预先配置的次数,则可以将该消息移到死信队列
  • A message is pushed onto a queue using SendMessage (it can remain in the queue for up to 14 days)
  • An application uses ReceiveMessage to retrieve a message from the queue (no guarantee of first-in-first-out)
  • When the application has finished processing the message, it calls DeleteMessage (it can also call ChangeMessageVisibility to extend the time until it times-out)
  • If the application does not delete the message within a pre-configured time period, SQS makes the message reappear on the queue
  • If a message is retrieved from the queue more than a pre-configured number of times, the message can be moved to a Dead Letter queue

无法获取有关特定消息的信息.相反,应用程序会要求提供一条消息(或一批消息),在此消息上,消息将变得不可见(或飞行中")).这也提供了对 ReceiptHandle 的访问,该代码可以与 DeleteMessage ChangeMes​​sageVisibility 一起使用.

It is not possible to obtain information about a specific message. Rather, the application asks for a message (or a batch of messages), upon which the message becomes invisible (or 'in flight'). This also gives access to a ReceiptHandle that can be used with DeleteMessage or ChangeMessageVisibility.

最接近的选项是调用 GetQueueAttributes . roximateNumberofMessagesNotVisible 的值将指示运行中的消息数,但不会深入了解特定消息.

The closest option is to call GetQueueAttributes. The value for ApproximateNumberOfMessagesNotVisible will indicate the number of in-flight messages but it will not give insight into a particular message.

这篇关于我能否确定Amazon SQS消息是否仍在发送中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆