Skip to content

Instantly share code, notes, and snippets.

@robertz
Created July 18, 2016 16:26
Show Gist options
  • Save robertz/3b493d5e22735f9acd2a3acc11e829b9 to your computer and use it in GitHub Desktop.
Save robertz/3b493d5e22735f9acd2a3acc11e829b9 to your computer and use it in GitHub Desktop.
component {
property name = "SQSService" inject = "model";
public function sendMessage(required string message) {
SQSService.sendMessage(queue = "test", message = arguments.message);
return;
}
public function startQueue() {
cfthread(name = "sqs-poll", action = "run", SQSService = SQSService) {
setting requestTimeout = 2147483647; // https://groups.google.com/forum/#!topic/lucee/Xxrb9fTVPAk
thread.done = false;
while(!thread.done){
var response = xmlParse(SQSService.receiveMessage(queue = "test"));
for(var item in response.xmlRoot.receiveMessageResult.xmlChildren) {
// do stuff
SQSService.deleteMessage(queue = "test", receiptHandle = item.receiptHandle.xmlText);
}
sleep(15000); // 15 seconds
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment