当消息出现在SQS队列中时触发AWS中的Lambda函数 [英] Trigger Lambda Function in AWS when the message is present in SQS Queue

查看:41
本文介绍了当消息出现在SQS队列中时触发AWS中的Lambda函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用AWS Lambda函数来处理Queue中的消息,它工作正常.但是,当消息可用或已添加到SQS队列中时,我需要执行此Lambda函数.

I am using AWS Lambda function to process the messages in Queue it's working fine. But i need to execute this Lambda function when messages available or added in SQS queue.

是否有可能基于SQS队列触发Lambda函数.请提出一种实现此目标的方法.

Is it possible to trigger the Lambda function based on SQS queue.Please suggest one method to achieve this goal.

推荐答案

不直接支持从SQS队列调用Lambda函数.您可以在此处查看可用触发器的列表: http://docs.aws.amazon.com/lambda/latest/dg/invoking-lambda-function.html

Invoking Lambda functions from SQS queues is not directly supported. You can see the list of available triggers here: http://docs.aws.amazon.com/lambda/latest/dg/invoking-lambda-function.html

可能的解决方案:

  1. 用Kinesis或DynamoDB替换SQS队列.两者都可以在更新时触发Lambda函数.
  2. 在SQS之前注入SNS.SNS可以将项目添加到SQS 触发Lambda函数.
  1. Replace SQS queue with Kinesis or DynamoDB. Both can trigger Lambda functions on updates.
  2. Inject SNS before SQS. SNS can add items to SQS and trigger Lambda function.

如果您不需要近乎实时的处理,这两个选项也是有效的:

If you don't need near real-time processing, these two options are also valid:

  1. 创建CloudWatch事件规则,该规则将每N分钟(例如,每分钟)触发一次Lambda函数.
  2. 为您的SQS队列
  3. 创建CloudWatch警报监视 roximateNumberofMessagesVisible 参数.该警报应发布到SNS主题,这将触发Lambda函数.
  1. Create CloudWatch Event Rule that will trigger the Lambda function every N minutes (e.g. every minute).
  2. Create CloudWatch alarm watching ApproximateNumberOfMessagesVisible parameter for your SQS queue. This alarm should publish to an SNS topic, which in turn will trigger Lambda function.

这篇关于当消息出现在SQS队列中时触发AWS中的Lambda函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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