nats
nats

Reputation: 197

cloudwatch rule from sqs to lambda

I have defined a trigger to my lambda from SQS queue. I want the Lambda to get invoked after every 2 hours and pick 15k messages from the queue.

Is it possible?

If yes, then how. Thanks!

Upvotes: 0

Views: 548

Answers (2)

victorperezpiqueras
victorperezpiqueras

Reputation: 375

I had a similar problem and, in my case, I changed the lambda to be triggered by a cron schedule (in your case, 2 hours). Then, in the lambda function you can query the AWS SQS API to get the messages in the queue. You may use ReceiveMessage method to retrieve the messages of the queue.

Upvotes: 0

smac2020
smac2020

Reputation: 10704

This is very possible. You can write a Lambda function that uses the AWS SQS API to retrieve messages from a queue. Then you can use scheduled events to define when a Lambda function is invoked. You can use a CRON expression to set the schedule. If you are not familiar with using CRON Expressions to define when a Lambda function is invoked, see this example.

This is implemented in Java - but you can still set a schedule event regardless of what programming language is used to develop the Lambda function:

https://github.com/awsdocs/aws-doc-sdk-examples/tree/master/javav2/usecases/creating_scheduled_events

Upvotes: 2

Related Questions