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

查看:111
本文介绍了将消息发布回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天全站免登陆