AWS SQS FIFO-如何一次获取十条以上消息? [英] AWS SQS FIFO - How to get more than 10 messages at a time?

查看:413
本文介绍了AWS SQS FIFO-如何一次获取十条以上消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我们要下拉整个FIFO队列,并处理内容,如果有问题,则将消息释放回队列.

Currently we want to pull down an entire FIFO queue, and process the contents, and if any issues, release messages back into the queue.

问题是,在我们删除或释放前10条消息之前,当前AWS仅给我们10条消息,而不会给我们10条消息(这是您在SQS中获得批量消息的方式,即10条最大消息请求).

The problem is, that currently AWS only gives us 10 messages, and won't give us 10 more (which is the way you get bulk messages in SQS, multiple 10 max message requests) until we delete or release the first 10.

不过我们需要获得10个以上.这不可能吗?我们知道我们可以将group_id设置为随机字符串,这样可以进行更多处理,但是不能保证顺序,这违背了FIFO的目的.

We need to get more than 10 though. Is this not possible? We understand we can set the group_id to a random string, and that allows processing more, but then the order isn't guaranteed, which defeats the purpose of FIFO.

推荐答案

我设法重现了您的结果-我可以检索10条消息,但是再次运行同一命令不会返回另一组消息.

I managed to reproduce your results -- I could retrieve 10 messages, but then running the same command again would not return another set of messages.

相关文档似乎是:

虽然具有特定MessageGroupId的消息是不可见的,但直到可见性超时到期,才不会再返回属于同一MessageGroupId的消息.只要仍然可见,您仍然可以通过另一个MessageGroupId接收消息.

While messages with a particular MessageGroupId are invisible, no more messages belonging to the same MessageGroupId are returned until the visibility timeout expires. You can still receive messages with another MessageGroupId as long as it is also visible.

我怀疑(只是一个理论!)这是为了保留消息的顺序...如果客户端请求一组消息并且它们仍在处理中,则可能会将消息返回给队列.因此,在删除原始消息或超过其可见性超时之前,将不再提供其他消息.

I suspect (just a theory!) that this is to preserve the ordering of messages... If a client asked for a set of messages and they are still being processed, there is the chance that the messages might be returned to the queue. Therefore, no further messages are provided until the original messages are deleted or pass their visibility timeout.

这只是FIFO队列的一种行为.

This is only a behaviour of FIFO queues.

您似乎需要接收并删除所有邮件,才能访问所有邮件.我建议:

It seems that you will need to receive and delete all messages to be able to access them all. I would suggest:

  • 接收一条(或更多)消息.
  • 处理它.如果一切正常,请删除该消息.
  • 如果有问题,请将消息推送到新队列.
  • 一旦队列为空,您将需要从新队列中读取并将其发送回原始队列(应保留顺序).
  • Receive one (or more) message.
  • Process it. If everything worked, delete the message.
  • If there were problems, push the message to a new queue.
  • Once the queue is empty, you would need to read from the new queue and send them back to the original queue (which should preserve ordering).

如果您经常需要Amazon SQS提供的更多功能,则可以考虑使用 Amazon MQ –托管消息代理ActiveMQ服务.它具有更多的功能(但因此简单"程度较低).

If you frequently require more capabilities that Amazon SQS provides, you could consider using Amazon MQ – Managed message broker service for ActiveMQ. It has many more capabilities (but is accordingly less 'simple').

这篇关于AWS SQS FIFO-如何一次获取十条以上消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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