将消息发布回 SQS [英] Release a message back to SQS

查看:53
本文介绍了将消息发布回 SQS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些 EC2 服务器从 SQS 队列中提取工作.偶尔,他们会遇到无法完成工作的情况.我有过程电子邮件我的条件.就目前而言,消息保持飞行中"直到超时.我希望该进程在发送电子邮件后立即将其释放回队列.但是,我不确定如何实现这一点.有办法吗?如果是这样,您能否将我指向电话或发布代码片段.

I have a some EC2 servers pulling work off of a SQS queue. Occasionally, they encounter a situation where the can't finish the job. I have the process email me of the condition. As it stands now, the message stays "in flight" until it times out. I would like for the process to immediately release it back to the queue after the email is sent. But, I'm not sure how to accomplish this. Is there a way? If so, can you please point me to the call or post a code snippet.

我使用的是 Python 2.7.3 和 Boto 2.5.2.

I'm using Python 2.7.3 and Boto 2.5.2.

推荐答案

如果您已经阅读了一条消息并出于某种原因决定不想处理它,而是希望立即将其提供给其他读者队列中,您可以简单地使用 boto 中 Message 对象的 change_visibility 方法将该消息的 visibility timeout 设置为零.有关详细信息,请参阅SQS 开发人员指南.

If you have read a message and decide, for whatever reason, that you do not want to process it and would rather make it immediately available to other readers of the queue, you can simply set that message's visibility timeout to zero using the change_visibility method of the Message object in boto. See The SQS Developer's Guide for details.

这篇关于将消息发布回 SQS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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