Skip to content

Conversation

@whummer
Copy link
Member

@whummer whummer commented Mar 10, 2020

Add message polling mechanism for Lambda-SQS integration.

This is a follow-up PR for the change in #2139 . Prior to this change, we used to intercept incoming SQS messages, check if they are linked to a Lambda function (via an event source mapping), and in that case call the Lambda directly with the event message, without forwarding the message to the actual SQS queue. This approach is fundamentally flawed, because Lambdas need to have access to the actual message receiptHandle in order to manipulate messages in the queue.

With this PR, we now implement an approach that is more in line with what's happening in real AWS. We're forwarding all SQS messages to the queues in all cases, and use a polling thread in the Lambda API to poll SQS queues for new messages. We're using a short-polling approach (receive_message with zero wait time), as we want to monitor several queues in parallel, in regular intervals (currently configured to poll every second).

Should fix #2039.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 50.639% when pulling 57c97cf on lambda-sqs-poll into b90c444 on master.

@whummer whummer merged commit b31f6e5 into master Mar 11, 2020
@whummer whummer deleted the lambda-sqs-poll branch March 11, 2020 01:32
jgbmattos pushed a commit to jgbmattos/localstack that referenced this pull request Mar 11, 2020
jgbmattos pushed a commit to jgbmattos/localstack that referenced this pull request Mar 11, 2020
jgbmattos pushed a commit to jgbmattos/localstack that referenced this pull request Mar 11, 2020
…2145)

Added support to redrive policy on SNS product.
It was necessary to change the lambda_api.process_sns_notification raise exception to the function caller and then handle the error for redrive policy work properly.

add test to assert presence of message Subject in SNS Lambda events (localstack#2143)

Add message polling mechanism for Lambda-SQS integration (localstack#2145)
jgbmattos pushed a commit to jgbmattos/localstack that referenced this pull request Mar 11, 2020
…2145)

Added support to redrive policy on SNS product.
It was necessary to change the lambda_api.process_sns_notification raise exception to the function caller and then handle the error for redrive policy work properly.

add test to assert presence of message Subject in SNS Lambda events (localstack#2143)

Add message polling mechanism for Lambda-SQS integration (localstack#2145)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQS ChangeMessageVisibility from within Lambda function

2 participants