触发S3创建事件 [英] Trigger S3 create event

查看:147
本文介绍了触发S3创建事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用S3 Create事件触发AWS-Lambdas.如果我的处理失败,我想做一些魔术,然后再次触发事件"以开始我的处理.到目前为止,我看到的唯一选择是重新上传文件.

I use S3 Create events to trigger AWS-Lambdas. If my processing fails I want to do some magic and then trigger the "event" again to start my processing ones more. So far the only option I see to do this is re-uploading the file.

是否可以再次触发事件而无需重新上传文件?

Can I trigger the event "again" without re-uploading the file?

我使用Python和boto3.

I use Python and boto3.

推荐答案

如果不重新上传文件,则不可能再次具有S3事件触发器.但是,对于失败的处理事件,如果您使用的是Lambda,则会根​​据常见问题解答:

It is not possible to have an S3 Event trigger again without uploading the file again. However, for a failed processing event if you are using Lambda it will automatically be retried 3 times per the FAQ:

对于Amazon S3存储桶通知和自定义事件,AWS Lambda将 如果发生以下情况,请尝试执行函数三次 代码中的错误情况,或者如果您超出了服务或资源 限制.

For Amazon S3 bucket notifications and custom events, AWS Lambda will attempt execution of your function three times in the event of an error condition in your code or if you exceed a service or resource limit.

如果处理失败,并且您想对重试进行更多控制,则可以使用SQS接收S3事件.这样,您的应用程序就可以从队列中读取消息,并且如果处理失败/失败,则最终将达到可见性超时,并且可以再次处理SQS消息.这样,您可以无限期重试,还可以控制连续重试之间的可见性超时时间.

If your processing is failing and you want to have more control over the retry you could instead use SQS to receive the S3 Events. That way your application is able to read messages off the queue and if the processing failes/dies the visibility timeout will eventually be reached and the SQS message can be processed again. This way you can retry indefinitely and also control the visibility timeout period between successive retries.

如果您正在使用Lambda并希望结合使用SQS,则可以通过安排每5分钟运行一次Lambda函数并使该Lambda函数从队列中读取消息来实现此目的.再加上5分钟的Lambda函数运行时间限制,您几乎可以连续消耗SQS队列中的消息.

If you are using Lambda and want to use SQS in combination, this is still possible by scheduling a Lambda function to run every 5 minutes and have that Lambda function read messages off of the queue. Combine this with the 5 minute limit for a Lambda functions run time you can nearly continuously consume messages off of an SQS queue.

这篇关于触发S3创建事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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