SQS messages remain in flight though it has been processed by lamdba












0















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










share|improve this question

























  • Have you deleted the message? SQS doesn't automatically delete the message for you.

    – stdunbar
    Nov 21 '18 at 16:35













  • Lambda is supposed to auto delete after a successful response is my understanding

    – Siddharth Ram
    Nov 21 '18 at 16:36











  • Lambda does what your code tells it to do. I've never heard of it doing anything like that.

    – stdunbar
    Nov 21 '18 at 16:37











  • docs.aws.amazon.com/lambda/latest/dg/with-sqs.html . Lambda polls the queue and invokes your function synchronously with an event that contains queue messages. Lambda reads messages in batches and invokes your function once for each batch. When your function successfully processes a batch, Lambda deletes its messages from the queue.

    – Siddharth Ram
    Nov 21 '18 at 16:40






  • 1





    I see a forEach in 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
    Nov 21 '18 at 16:58
















0















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










share|improve this question

























  • Have you deleted the message? SQS doesn't automatically delete the message for you.

    – stdunbar
    Nov 21 '18 at 16:35













  • Lambda is supposed to auto delete after a successful response is my understanding

    – Siddharth Ram
    Nov 21 '18 at 16:36











  • Lambda does what your code tells it to do. I've never heard of it doing anything like that.

    – stdunbar
    Nov 21 '18 at 16:37











  • docs.aws.amazon.com/lambda/latest/dg/with-sqs.html . Lambda polls the queue and invokes your function synchronously with an event that contains queue messages. Lambda reads messages in batches and invokes your function once for each batch. When your function successfully processes a batch, Lambda deletes its messages from the queue.

    – Siddharth Ram
    Nov 21 '18 at 16:40






  • 1





    I see a forEach in 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
    Nov 21 '18 at 16:58














0












0








0








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










share|improve this question
















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







aws-lambda amazon-sqs






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 27 '18 at 22:50







Siddharth Ram

















asked Nov 21 '18 at 16:32









Siddharth RamSiddharth Ram

301211




301211













  • Have you deleted the message? SQS doesn't automatically delete the message for you.

    – stdunbar
    Nov 21 '18 at 16:35













  • Lambda is supposed to auto delete after a successful response is my understanding

    – Siddharth Ram
    Nov 21 '18 at 16:36











  • Lambda does what your code tells it to do. I've never heard of it doing anything like that.

    – stdunbar
    Nov 21 '18 at 16:37











  • docs.aws.amazon.com/lambda/latest/dg/with-sqs.html . Lambda polls the queue and invokes your function synchronously with an event that contains queue messages. Lambda reads messages in batches and invokes your function once for each batch. When your function successfully processes a batch, Lambda deletes its messages from the queue.

    – Siddharth Ram
    Nov 21 '18 at 16:40






  • 1





    I see a forEach in 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
    Nov 21 '18 at 16:58



















  • Have you deleted the message? SQS doesn't automatically delete the message for you.

    – stdunbar
    Nov 21 '18 at 16:35













  • Lambda is supposed to auto delete after a successful response is my understanding

    – Siddharth Ram
    Nov 21 '18 at 16:36











  • Lambda does what your code tells it to do. I've never heard of it doing anything like that.

    – stdunbar
    Nov 21 '18 at 16:37











  • docs.aws.amazon.com/lambda/latest/dg/with-sqs.html . Lambda polls the queue and invokes your function synchronously with an event that contains queue messages. Lambda reads messages in batches and invokes your function once for each batch. When your function successfully processes a batch, Lambda deletes its messages from the queue.

    – Siddharth Ram
    Nov 21 '18 at 16:40






  • 1





    I see a forEach in 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
    Nov 21 '18 at 16:58

















Have you deleted the message? SQS doesn't automatically delete the message for you.

– stdunbar
Nov 21 '18 at 16:35







Have you deleted the message? SQS doesn't automatically delete the message for you.

– stdunbar
Nov 21 '18 at 16:35















Lambda is supposed to auto delete after a successful response is my understanding

– Siddharth Ram
Nov 21 '18 at 16:36





Lambda is supposed to auto delete after a successful response is my understanding

– Siddharth Ram
Nov 21 '18 at 16:36













Lambda does what your code tells it to do. I've never heard of it doing anything like that.

– stdunbar
Nov 21 '18 at 16:37





Lambda does what your code tells it to do. I've never heard of it doing anything like that.

– stdunbar
Nov 21 '18 at 16:37













docs.aws.amazon.com/lambda/latest/dg/with-sqs.html . Lambda polls the queue and invokes your function synchronously with an event that contains queue messages. Lambda reads messages in batches and invokes your function once for each batch. When your function successfully processes a batch, Lambda deletes its messages from the queue.

– Siddharth Ram
Nov 21 '18 at 16:40





docs.aws.amazon.com/lambda/latest/dg/with-sqs.html . Lambda polls the queue and invokes your function synchronously with an event that contains queue messages. Lambda reads messages in batches and invokes your function once for each batch. When your function successfully processes a batch, Lambda deletes its messages from the queue.

– Siddharth Ram
Nov 21 '18 at 16:40




1




1





I see a forEach in 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
Nov 21 '18 at 16:58





I see a forEach in 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
Nov 21 '18 at 16:58












1 Answer
1






active

oldest

votes


















0














You seem to be missing some closing parenthesis/curly braces.
Is the handler callback being called in the handleSQSMessages callback? It's hard to tell with the missing braces - but if not, that's probably the reason it's failing.






share|improve this answer
























  • I posted a snippet. The code runs fine. I store the data in aurora, which is exactly what I intend. However, the messages do not get deleted from SQS though the callback is invoked

    – Siddharth Ram
    Jan 28 at 15:03











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53416592%2fsqs-messages-remain-in-flight-though-it-has-been-processed-by-lamdba%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














You seem to be missing some closing parenthesis/curly braces.
Is the handler callback being called in the handleSQSMessages callback? It's hard to tell with the missing braces - but if not, that's probably the reason it's failing.






share|improve this answer
























  • I posted a snippet. The code runs fine. I store the data in aurora, which is exactly what I intend. However, the messages do not get deleted from SQS though the callback is invoked

    – Siddharth Ram
    Jan 28 at 15:03
















0














You seem to be missing some closing parenthesis/curly braces.
Is the handler callback being called in the handleSQSMessages callback? It's hard to tell with the missing braces - but if not, that's probably the reason it's failing.






share|improve this answer
























  • I posted a snippet. The code runs fine. I store the data in aurora, which is exactly what I intend. However, the messages do not get deleted from SQS though the callback is invoked

    – Siddharth Ram
    Jan 28 at 15:03














0












0








0







You seem to be missing some closing parenthesis/curly braces.
Is the handler callback being called in the handleSQSMessages callback? It's hard to tell with the missing braces - but if not, that's probably the reason it's failing.






share|improve this answer













You seem to be missing some closing parenthesis/curly braces.
Is the handler callback being called in the handleSQSMessages callback? It's hard to tell with the missing braces - but if not, that's probably the reason it's failing.







share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 27 '18 at 7:51









esther hesther h

80021230




80021230













  • I posted a snippet. The code runs fine. I store the data in aurora, which is exactly what I intend. However, the messages do not get deleted from SQS though the callback is invoked

    – Siddharth Ram
    Jan 28 at 15:03



















  • I posted a snippet. The code runs fine. I store the data in aurora, which is exactly what I intend. However, the messages do not get deleted from SQS though the callback is invoked

    – Siddharth Ram
    Jan 28 at 15:03

















I posted a snippet. The code runs fine. I store the data in aurora, which is exactly what I intend. However, the messages do not get deleted from SQS though the callback is invoked

– Siddharth Ram
Jan 28 at 15:03





I posted a snippet. The code runs fine. I store the data in aurora, which is exactly what I intend. However, the messages do not get deleted from SQS though the callback is invoked

– Siddharth Ram
Jan 28 at 15:03


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53416592%2fsqs-messages-remain-in-flight-though-it-has-been-processed-by-lamdba%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Paul Cézanne

UIScrollView CustomStickyHeader Resize height generates problems when scroll is too fast

Angular material date-picker (MatDatepicker) auto completes the date on focus out