Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
SQS recursive polling
var aws = require('aws-sdk');
var util = require('util');
var SQS = new aws.SQS({
accessKeyId: 'xxxx',
secretAccessKey: 'xxx',
region: 'xxx',
sslEnabled: false,
paramValidation: true,
convertResponseTypes: true,
apiVersion: "2012-11-05"
});
var queueUrl = 'xxxxx';
var formatMsg = function (mem) {
console.log([mem.rss, mem.heapTotal, mem.heapUsed].join(','));
};
var getMessage = function () {
formatMsg(process.memoryUsage());
SQS.receiveMessage({
QueueUrl: queueUrl,
MaxNumberOfMessages: 1,
VisibilityTimeout: 30,
WaitTimeSeconds: 20
}, function (err) {
if (err) {
return err;
}
// No need for result
// console.log(res);
// Recursive call
getMessage();
});
};
getMessage();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment