是否可以在将项目添加到 SQS 队列时触发 AWS Fargate 任务? [英] Is it possible to trigger an AWS Fargate task upon an item being added to an SQS queue?

查看:25
本文介绍了是否可以在将项目添加到 SQS 队列时触发 AWS Fargate 任务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了澄清起见,我想要做的是在特定队列中有项目时触发 Fargate 任务.我使用过本教程 几乎可以到达我所在的位置.这工作正常,但我遇到的问题是每个文件上传(s3 存储桶的结构是 s3_bucket_name/{unknown_name}/known_file_names)导致任务被触发,我只希望/需要它每个 {unknown_name} 触发一次.从那以后,我更改了配置,以便在检测到 test_file.txt 文件时将项目添加到队列中.是否可以在这样的队列上触发 fargate 任务?如果是这样,如何?

For clarification, what I'm trying to do is fire off a Fargate task when theres an item in a specific queue. I've used this tutorial to get pretty much where I am. This worked fine but the problem I ran into was every file upload (the structure of the s3 bucket is s3_bucket_name/{unknown_name}/known_file_names) was resulting in a task being triggered and I only want/need it to trigger once per {unknown_name} . I've since changed my configuration to add an item to a queue when it detects a test_file.txt file. Is it possible to trigger a fargate task on a queue like this? If so, how?

推荐答案

SQS 不会触发或推送"消息给任何东西.正如评论中所述,AWS Lambda 具有 SQS 集成,可以自动为您轮询 SQS 并使用新消息触发 Lambda 函数,您可以使用它来创建 Fargate 任务.

SQS doesn't trigger or "push" messages to anything. As mentioned in the comments, AWS Lambda has an SQS integration that can automatically poll SQS for you and trigger a Lambda function with new messages, which you could use to create your Fargate tasks.

不过,我建议您像这样重构 Fargate 任务:

However I would recommend refactoring your Fargate task like this:

  • 重新配置容器中运行的代码以轮询 SQS 队列以获取消息.
  • 将您的任务作为 ECS 服务运行.
  • 配置 ECS 服务自动缩放以根据 SQS 队列的深度启动任务实例.

这篇关于是否可以在将项目添加到 SQS 队列时触发 AWS Fargate 任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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