Created
March 5, 2015 19:16
-
-
Save riston/087124c2323b00167576 to your computer and use it in GitHub Desktop.
SQS recursive polling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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