Created
January 16, 2010 02:44
-
-
Save iogi/278613 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
<?php | |
require 'Services/Amazon/SQS/Queue.php'; | |
define('AMAZON_ACCESS_KEY', your access key); | |
define('AMAZON_SECRET_ACCESSKEY', your secret access key); | |
// queueのURIを指定 | |
define('QUEUE_URL', 'http://queue.amazonaws.com/508403871985/test-queue'); | |
$sqs = new Services_Amazon_SQS_Queue(QUEUE_URL, AMAZON_ACCESS_KEY, AMAZON_SECRET_ACCESSKEY); | |
while(1) { | |
// 1件だけ取得 | |
list($item) = $sqs->receive(1); | |
if (empty($item)) { | |
echo 'queue is empty!', PHP_EOL; | |
sleep(10); | |
continue; | |
} | |
echo 'item body is ', $item['body'], PHP_EOL; | |
// ここで時間のかかる作業をやる | |
$sqs->delete($item['handle']); | |
echo 'item delete.', PHP_EOL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment