Reputation: 479
I have a AWS Lambda function which is deployed in console. Since, it will consume the message from some external queue automatically,I want it to be keep on running continuously instead of scheduling. How can I make aws lambda to run continuously?
Upvotes: 2
Views: 5623
Reputation: 461
You can add a trigger to your Lambda, and set the SQS queue you want to respond to. In the AWS console (on the web), you can either do this from the Lambda functions itself, or from SQS (i'd advise this strategy). The console will guide you through the details for setting up the proper security stuff. More info on the setup: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-configure-lambda-function-trigger.html
Some general info on consuming SQS messages in Lambda: https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html
Your preferred programming language probably has a client library that implements the API for you.
IMPORTANT: If you want to process your queue sequentially, make sure you set the reserved concurrency of your lambda to 0.
Also, if you use CLI or other automatic deploy tools, make sure to update your config files, so you don't overwrite your Lambda's settings on deploy.
EDIT: when you say external queue; you mean a non SQS queue? I guess it could still be done with another system. Best way to do it is to raise an event. Trigger the Lambda with a http request when a message is added. If for some reason you can't do this, you could add a schedule for your Lambda, and run it, let's say every 5 minutes. More info on scheduling: https://docs.aws.amazon.com/eventbridge/latest/userguide/run-lambda-schedule.html
Upvotes: 3
Reputation: 86
If instead of an external queue you could use the SQS provided by AWS you could set that queue as a trigger to your Lambda function and have it execute once a new item is set on the queue.
Upvotes: 1