如何使用SQS(Amazon简单队列服务)实现优先级队列

编程入门 行业动态 更新时间:2024-10-08 10:49:53
本文介绍了如何使用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简单队列服务)实现优先级队列

本文发布于:2023-11-29 06:09:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1645562.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:队列   优先级   如何使用   简单   Amazon

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!