SQS messages get processed successfully by lambda. Here is the code that processes and then executes the callback:
exports.handler = function(event, context, callback) {
handleSQSMessages(context,event, function () {
const response = {
statusCode: 200,
body: JSON.stringify({
message: 'SQS event processed.',
input: event,
}),
};
console.log ("OK DONE");
callback(null, response);
function handleSQSMessages(context, messages, callback) {
messages = messages.Records;
if (messages && messages.length > 0) {
messages.forEach(function(message) {
console.log(message);
//...
I see that cloudwatch prints the "OK DONE" message. However, SQS puts messages 'in flight' (and it stays in flight forever). My understanding is that once a successful response is sent, the message will be automatically deleted. My visibility timer = 10 min
forEachin the AWS examples. Your link says that if you don't respond to the batch (i.e. all the messages that your are given) then it does not delete the messages. Are you reading everything given? - stdunbar