如何使用SQS(Amazon简单队列服务)实现优先级队列 [英] How to implement a priority queue using SQS(Amazon simple queue service)

查看:80
本文介绍了如何使用SQS(Amazon简单队列服务)实现优先级队列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一种情况,当味精失败时,我想使用python boto软件包重播具有最高优先级的味精,因此将首先采取该方法.如果我没弄错,SQS队列不支持优先级队列,那么我想实现一些简单的方法.

I have a situation when a msg fails and I would like to replay that msg with the highest priority using python boto package so he will be taken first. If I'm not wrong SQS queue does not support priority queue, so I would like to implement something simple.

重要提示:当味精失败时,我不再拥有消息对象,我只保留了receive_handle,以便可以删除消息(如果重试次数超过x次)/更改超时可见性为了将他推回队列.

Important note: when a msg fails I no longer have the message object, I only persist the receipt_handle so I can delete the message(if there was more than x retries) / change timeout visibility in order to push him back to queue.

谢谢!

推荐答案

我认为没有任何方法可以对单个SQS队列执行此操作.您无法控制邮件的传递,因此无法对邮件施加优先级.如果您找到方法,我很想听听.

I don't think there is any way to do this with a single SQS queue. You have no control over delivery of messages and, therefore, no way to impose a priority on messages. If you find a way, I would love to hear about it.

我认为您可以使用两个队列(或更常见的是N个队列,其中N是优先级数),但是即使在您确定消息对象实际上没有消息对象时,这似乎也不可能失败的.您将需要message对象,以便可以将数据写入高优先级队列.

I think you could possibly use two queues (or more generally N queues where N is the number of levels of priority) but even this seems impossible if you don't actually have the message object at the time you determine that it has failed. You would need the message object so that the data could be written to the high-priority queue.

我不确定这实际上是否可以作为答案8 ^)

I'm not sure this actually qualifies as an answer 8^)

这篇关于如何使用SQS(Amazon简单队列服务)实现优先级队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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