Last active
May 10, 2016 06:28
-
-
Save mikeplavsky/5ffe7e33e0d70a248537 to your computer and use it in GitHub Desktop.
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
"use strict"; | |
var AWS = require("aws-sdk"); | |
var SQS = new AWS.SQS(); | |
var sendMsg = function sendMsg(event, cxt) { | |
var params = { | |
QueueName: "gc_go_indexer" | |
}; | |
SQS.createQueue(params, function(err, data) { | |
if (err) { | |
cxt.fail(err); | |
return; | |
} | |
var params = { | |
QueueUrl: data.QueueUrl | |
}; | |
SQS.purgeQueue(params, function(err, data){ | |
if (err) { | |
console.log("failed to purge"); | |
cxt.fail(err); | |
return; | |
} | |
console.log("sending message"); | |
var msg = { | |
QueueUrl: params.QueueUrl, | |
MessageBody: "Tick", | |
DelaySeconds: 10 * 60 | |
}; | |
SQS.sendMessage(msg, function(err, data) { | |
if (err) { | |
cxt.fail(err); | |
return; | |
} | |
SQS.sendMessage(msg, function(err, data){ | |
if (err) { | |
cxt.fail(err); | |
return; | |
} | |
SQS.sendMessage(msg, function(err, data){ | |
if (err) { | |
cxt.fail(err); | |
return; | |
} | |
console.log("sent third message"); | |
cxt.done(); | |
}); | |
console.log("sent second message"); | |
}); | |
console.log("sent first message"); | |
}); | |
}); | |
}); | |
}; | |
exports.sendMsg = sendMsg; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment