2

Is it possible to create a lambda which is triggered manually to read from an SQS.

I have an SQS queue which is constantly receiving messages, I want to process them when I want to (not continuous sync processing).

Can I have something like a start/stop lambda, where I start the lambda, and it consumes actively from SQS and when I stop it stops consuming

John Rotenstein
273k28 gold badges457 silver badges543 bronze badges
asked Sep 29, 2020 at 21:17
1
  • Can you describe your architecture better? It doesn't sound like you're using SQS for it's intended purpose. Yes, you can manually trigger it but I don't understand why you're using SQS and Lambda then. Commented Sep 30, 2020 at 0:21

1 Answer 1

1

Normally, an AWS Lambda function is configured to "trigger" from an Amazon SQS queue. Whenever a message arrives, a Lambda function would be triggered.

However, instead of configuring a trigger, you could code an AWS Lambda function to call ReceiveMessages() on the queue itself. The Lambda function would then be responsible for calling DeleteMessage() after the message has been processed.

You can invoke a Lambda function at any time by using the Invoke() command.

The only decision you would need to make is whether the Lambda function should process:

  • One message per invocation, or
  • One batch of messages (up to 10) per invocation, or
  • Run a loop that keeps retrieving messages from the queue until the queue is empty or until the Lambda function times-out (which could leave a message partially processed, so it isn't a good idea)
answered Sep 29, 2020 at 22:30
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.