public function count($queueName) { $response = $this->sqs->get_queue_size($queueName); if (is_numeric($response)) { return $response; } else { return $this->parseResponse($response); } }
/** * {@inheritdoc} */ public function updateQueue($queueName, array $queueOptions = array()) { $attributes = array(); foreach ($queueOptions as $name => $value) { $attributes[] = array('Name' => $name, 'Value' => $value); } $this->parseResponse($this->sqs->set_queue_attributes($this->getQueueUrl($queueName), $attributes)); return true; }
/** * @covers mychaelstyle\queue\providers\AmazonSQS::connect * @covers mychaelstyle\queue\providers\AmazonSQS::poll * @covers mychaelstyle\queue\providers\AmazonSQS::offer * @covers mychaelstyle\queue\providers\AmazonSQS::peek * @covers mychaelstyle\queue\providers\AmazonSQS::remove */ public function testOfferMap() { $expected = array('first_name' => 'Taro', 'last_name' => 'Suzuki'); $this->object->offer($expected); $result = (array) $this->object->poll(); $this->assertEquals($expected, $result); $result = $this->object->poll(); $this->assertNull($result); }
public function getValue(DBFarmRole $dbFarmRole, Scalr_Scaling_FarmRoleMetric $farmRoleMetric) { $dbFarm = $dbFarmRole->GetFarmObject(); $AmazonSQS = AmazonSQS::GetInstance($dbFarm->GetEnvironmentObject()->getPlatformConfigValue(Modules_Platforms_Ec2::ACCESS_KEY), $dbFarm->GetEnvironmentObject()->getPlatformConfigValue(Modules_Platforms_Ec2::SECRET_KEY)); try { $res = $AmazonSQS->GetQueueAttributes($farmRoleMetric->getSetting(self::SETTING_QUEUE_NAME)); $retval = $res['ApproximateNumberOfMessages']; } catch (Exception $e) { throw new Exception(sprintf("SQSScalingSensor failed during SQS request: %s", $e->getMessage())); } return array($retval); }
public function __construct(array $options = array()) { if (!isset($options['default_cache_config'])) { $options['default_cache_config'] = 'cache/aws'; } if (!isset($options['key']) && Kwf_Config::getValue('aws.key')) { $options['key'] = Kwf_Config::getValue('aws.key'); } if (!isset($options['secret']) && Kwf_Config::getValue('aws.secret')) { $options['secret'] = Kwf_Config::getValue('aws.secret'); } parent::__construct($options); }
* may not use this file except in compliance with the License. A copy * of the License is located at * * http://aws.amazon.com/apache2.0/ * * or in the "license.txt" file accompanying this file. This file is * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS * OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the * License. */ error_reporting(E_ALL); require_once 'sdk.class.php'; require_once 'include/book.inc.php'; // Create the SQS and S3 access objects $sqs = new AmazonSQS(); $s3 = new AmazonS3(); // Get the Queue URLs $queueURL_URL = $sqs->create_queue(URL_QUEUE)->body->CreateQueueResult->QueueUrl; $queueURL_Parse = $sqs->create_queue(PARSE_QUEUE)->body->CreateQueueResult->QueueUrl; // Pull, process, post while (true) { // Pull the message from the queue $message = pullMessage($sqs, $queueURL_URL); if ($message != null) { // Extract message detail $messageDetail = $message['MessageDetail']; $receiptHandle = (string) $message['ReceiptHandle']; $pageURL = $messageDetail['Data']; // Fetch the page print "Processing URL '{$pageURL}':\n";
* * http://aws.amazon.com/apache2.0/ * * or in the "license.txt" file accompanying this file. This file is * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS * OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the * License. * * Modified by Jeffrey S. Haemer <*****@*****.**> */ error_reporting(E_ALL); require_once 'AWSSDKforPHP/sdk.class.php'; require_once 'include/book.inc.php'; // Create the SQS access object $sqs = new AmazonSQS(); // Form list of queues $queues = array(URL_QUEUE, PARSE_QUEUE, IMAGE_QUEUE, RENDER_QUEUE); // Titles $underlines = ''; foreach ($queues as $queueName) { printf("%-12s ", $queueName); $underlines .= str_repeat('-', strlen($queueName)) . str_repeat(' ', 12 - strlen($queueName)) . " "; } print "\n"; print $underlines . "\n"; // Report on each queue foreach ($queues as $queueName) { $res = $sqs->create_queue($queueName); if ($res->isOK()) { $queueURL = urlFromQueueObject($res);
* * or in the "license.txt" file accompanying this file. This file is * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS * OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the * License. */ error_reporting(E_ALL); require_once 'sdk.class.php'; require_once 'include/book.inc.php'; // Make sure that at least one argument was given if ($argc < 2) { exit('Usage: ' . $argv[0] . " URL...\n"); } // Create the SQS access object $sqs = new AmazonSQS(); // Get the Queue URL $queueURL = $sqs->create_queue(URL_QUEUE)->body->CreateQueueResult->QueueUrl; // Load each URL for ($i = 1; $i < $argc; $i++) { // Create message $histItem = array('Posted by ' . $argv[0] . ' at ' . date('c')); $message = json_encode(array('Action' => 'FetchPage', 'Origin' => $argv[0], 'Data' => $argv[$i], 'History' => $histItem)); // Post message $res = $sqs->send_message($queueURL, $message); if ($res->isOK()) { print "Posted '{$message}' to queue " . URL_QUEUE . "\n"; } else { $error = $res->body->Error->Message; print "Could not post message to queue: {$error}\n"; }
* may not use this file except in compliance with the License. A copy * of the License is located at * * http://aws.amazon.com/apache2.0/ * * or in the "license.txt" file accompanying this file. This file is * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS * OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the * License. */ error_reporting(E_ALL); require_once 'sdk.class.php'; require_once 'include/book.inc.php'; // Create the SQS access object $sqs = new AmazonSQS(); // Form list of queues $queues = array(URL_QUEUE, PARSE_QUEUE, IMAGE_QUEUE, RENDER_QUEUE); // Titles $underlines = ''; foreach ($queues as $queueName) { printf("%-12s ", $queueName); $underlines .= str_repeat('-', strlen($queueName)) . str_repeat(' ', 12 - strlen($queueName)) . " "; } print "\n"; print $underlines . "\n"; // Report on each queue foreach ($queues as $queueName) { $res = $sqs->create_queue($queueName); if ($res->isOK()) { $size = $sqs->get_queue_size($res->body->CreateQueueResult->QueueUrl);
* * http://aws.amazon.com/apache2.0/ * * or in the "license.txt" file accompanying this file. This file is * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS * OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the * License. * * Modified by Jeffrey S. Haemer <*****@*****.**> */ error_reporting(E_ALL); require_once 'AWSSDKforPHP/sdk.class.php'; // Make sure that at least one argument was supplied if (count($argv) < 2) { exit("Usage: " . $argv[0] . " QUEUE...\n"); } // Create the SQS access object $sqs = new AmazonSQS(); // Process each argument for ($i = 1; $i < count($argv); $i++) { $queue = $argv[$i]; $res = $sqs->create_queue($queue); if ($res->isOK()) { print "Created queue '{$queue}'\n"; } else { $error = (string) $res->body->Error->Message; print "Could not create queue '{$queue}': {$error}.\n"; } } exit(0);
<?php require_once '/usr/share/php/AWSSDKforPHP/sdk.class.php'; define('AWS_KEY', 'AKIAIGKECZXA7AEIJLMQ'); define('AWS_SECRET_KEY', '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'); define('AWS_ACCOUNT_ID', '457964863276'); # set priority $priority = $_GET['priority']; # construct the message $job_description = array('template' => 'https://s3-eu-west-1.amazonaws.com/production/templates/223/template_1.xml', 'assets' => 'https://s3-eu-west-1.amazonaws.com/production/assets/223', 'result' => 'https://s3-eu-west-1.amazonaws.com/production/pdfs/223'); $body = json_encode($job_description); $sqs = new AmazonSQS(); $sqs->set_region($sqs::REGION_EU_W1); if ('high' === $priority) { $high_priority_jobs_queue = $sqs->create_queue('high-priority-jobs'); $high_priority_jobs_queue->isOK() or die('could not create queue high-priority-jobs'); $response = $sqs->send_message($high_priority_jobs_queue->body->QueueUrl(0), $body); } else { $normal_priority_jobs_queue = $sqs->create_queue('normal-priority-jobs'); $normal_priority_jobs_queue->isOK() or die('could not create queue normal-priority-jobs'); $response = $sqs->send_message($normal_priority_jobs_queue->body->QueueUrl(0), $body); } pr($response->body); function pr($var) { print '<pre>'; print_r($var); print '</pre>'; }
* http://aws.amazon.com/apache2.0/ * * or in the "license.txt" file accompanying this file. This file is * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS * OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the * License. * * Modified by Jeffrey S. Haemer <*****@*****.**> */ error_reporting(E_ALL); require_once 'AWSSDKforPHP/sdk.class.php'; require_once 'include/simple_html_dom.php'; require_once 'include/book.inc.php'; // Create the SQS and S3 access objects $sqs = new AmazonSQS(); $s3 = new AmazonS3(); // Convert the queuenames to URLs $res = $sqs->create_queue(PARSE_QUEUE); if ($res->isOK()) { $parseQueueURL = urlFromQueueObject($res); } $res = $sqs->create_queue(IMAGE_QUEUE); if ($res->isOK()) { $imageQueueURL = urlFromQueueObject($res); } // Pull, process, post while (true) { // Pull the message from the queue $message = pullMessage($sqs, $parseQueueURL); if ($message != null) {
/** * Method: get_queue_size() * Identical to <AmazonSQS::get_queue_size()>, except that you don't need to pass in a queue URL. * * Access: * public * * Returns: * _integer_ The Approximate number of messages in the queue. * * See Also: * Example Usage - http://tarzan-aws.com/docs/examples/sqsqueue/get_queue_size.phps */ public function get_queue_size() { if ($this->queue_url) { return parent::get_queue_size($this->queue_url); } throw new SQSQueue_Exception(SQSQUEUE_DEFAULT_ERROR); }
<?php define('_PS_ADMIN_DIR_', getcwd()); define('PS_ADMIN_DIR', _PS_ADMIN_DIR_); // Retro-compatibility include PS_ADMIN_DIR . '/../config/config.inc.php'; include PS_ADMIN_DIR . '/functions.php'; $sqs = new AmazonSQS(); $sqs->set_region(AmazonSQS::REGION_APAC_SE1); $db = Db::getInstance(_PS_USE_SQL_SLAVE_); for ($count = 1; $count < 10; $count++) { $response = $sqs->receive_message(INVITE_QUEUE); if (!$response->body->ReceiveMessageResult->Message) { sleep(5); } else { if (processMessage($response, $db)) { } $handle = $response->body->ReceiveMessageResult->Message->ReceiptHandle; $sqs->delete_message(INVITE_QUEUE, $handle); } } /** * @param unknown_type $response * @param Db $db * @return boolean */ function processMessage($response, $db) { echo $response->body->ReceiveMessageResult->Message->Body . PHP_EOL; $message = Tools::jsonDecode($response->body->ReceiveMessageResult->Message->Body, true); $id_customer = $message['id_customer'];
* http://aws.amazon.com/apache2.0/ * * or in the "license.txt" file accompanying this file. This file is * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS * OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the * License. * * Modified by Jeffrey S. Haemer <*****@*****.**> */ error_reporting(E_ALL); require_once 'AWSSDKforPHP/sdk.class.php'; // Make sure that at least two arguments were supplied if ($argc < 3) { exit("Usage: " . $argv[0] . " QUEUE_NAME ITEM...\n"); } // Create the SQS access object $sqs = new AmazonSQS(); $queueName = $argv[1]; // Put each of the items into the queue for ($i = 2; $i < $argc; $i++) { $message = $argv[$i]; $res = $sqs->send_message($queueName, $message); if ($res->isOK()) { print "Posted '{$message}' to queue '{$queueName}'\n"; } else { $error = $res->body->Error->Message; print "Could not post message to queue: {$error}\n"; } } exit(0);
<?php require_once '/usr/share/php/AWSSDKforPHP/sdk.class.php'; define('AWS_KEY', 'AKIAIGKECZXA7AEIJLMQ'); define('AWS_SECRET_KEY', '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'); define('AWS_ACCOUNT_ID', '457964863276'); $queue_name = $_GET['queue']; $sqs = new AmazonSQS(); $sqs->set_region($sqs::REGION_EU_W1); $queue = $sqs->create_queue($queue_name); $queue->isOK() or die('could not create queue ' + $queue_name); $response = $sqs->get_queue_attributes($queue->body->QueueUrl(0), array('AttributeName' => 'All')); pr($response->body); function pr($var) { print '<pre>'; print_r($var); print '</pre>'; }
error_reporting(E_ALL); require_once 'AWSSDKforPHP/sdk.class.php'; // If called as "pull_queue.php --no-delete <queuename>" // show the queue contents but don't clear the queue. $delete = 'true'; if ($argc > 1 && $argv[1] == "--no-delete") { $delete = 'false'; array_splice($argv, 1, 1); $argc--; } // Make sure that an argument was supplied if ($argc != 2) { exit("Usage: " . $argv[0] . " [--no-delete] QUEUE_NAME\n"); } // Create the SQS access object $sqs = new AmazonSQS(); $queueName = $argv[1]; // Poll for new items while (true) { $res = $sqs->receive_message($queueName); if ($res->isOK()) { if (isset($res->body->ReceiveMessageResult->Message)) { $message = $res->body->ReceiveMessageResult->Message; $messageBody = $message->Body; $receiptHandle = (string) $message->ReceiptHandle; print "Message: '{$messageBody}'\n"; if ($delete == 'true') { $sqs->delete_message($queueName, $receiptHandle); } } else { sleep(1);
require_once 'AWSSDKforPHP/sdk.class.php'; require_once 'include/book.inc.php'; if ($argc != 2) { exit("Usage: " . $argv[0] . " bucket name\n"); } $bucket = $argv[1] == '-' ? BOOK_BUCKET : $argv[1]; // Define image layout constants define('BORDER_LEFT', 12); define('BORDER_RIGHT', 12); define('BORDER_TOP', 12); define('BORDER_BOTTOM', 12); define('IMAGES_ACROSS', 4); define('IMAGES_DOWN', 4); define('GAP_SIZE', 6); // Create the SQS and S3 access objects $sqs = new AmazonSQS(); $s3 = new AmazonS3(); // Convert the queuenames to URLs $res = $sqs->create_queue(RENDER_QUEUE); if ($res->isOK()) { $renderQueueURL = urlFromQueueObject($res); } // Pull, process while (true) { // Pull the message from the queue $message = pullMessage($sqs, $renderQueueURL); if ($message != null) { // Extract message detail $messageDetail = $message['MessageDetail']; $receiptHandle = (string) $message['ReceiptHandle']; $imageKeys = $messageDetail['Data'];
* http://aws.amazon.com/apache2.0/ * * or in the "license.txt" file accompanying this file. This file is * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS * OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the * License. */ error_reporting(E_ALL); require_once 'sdk.class.php'; // Make sure that an argument was supplied if ($argc != 2) { exit("Usage: " . $argv[0] . " QUEUE_NAME\n"); } // Create the SQS access object $sqs = new AmazonSQS(); $queueName = $argv[1]; // Get URL for queue $queueURL = $sqs->create_queue($queueName)->body->CreateQueueResult->QueueUrl; // Poll for new items while (true) { $res = $sqs->receive_message($queueURL); if ($res->isOK()) { if (isset($res->body->ReceiveMessageResult->Message)) { $message = $res->body->ReceiveMessageResult->Message; $messageBody = $message->Body; $receiptHandle = (string) $message->ReceiptHandle; print "Message: '{$messageBody}'\n"; $sqs->delete_message($queueURL, $receiptHandle); } else { sleep(1);
<?php require_once '/usr/share/php/AWSSDKforPHP/sdk.class.php'; define('AWS_KEY', 'AKIAIGKECZXA7AEIJLMQ'); define('AWS_SECRET_KEY', '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'); define('AWS_ACCOUNT_ID', '457964863276'); $queue_name = $_GET['queue']; $sqs = new AmazonSQS(); $sqs->set_region($sqs::REGION_EU_W1); $queue = $sqs->create_queue($queue_name); $queue->isOK() or die('could not create queue ' + $queue_name); $receive_response = $sqs->receive_message($queue->body->QueueUrl(0)); $delete_response = $sqs->delete_message($queue->body->QueueUrl(0), (string) $receive_response->body->ReceiptHandle(0)); $body = json_decode($receive_response->body->Body(0)); pr($body); function pr($var) { print '<pre>'; print_r($var); print '</pre>'; }
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS * OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the * License. * * Modified by Jeffrey S. Haemer <*****@*****.**> */ error_reporting(E_ALL); require_once 'AWSSDKforPHP/sdk.class.php'; require_once 'include/book.inc.php'; // Make sure that at least one argument was given if ($argc < 2) { exit('Usage: ' . $argv[0] . " URL...\n"); } // Create the SQS access object $sqs = new AmazonSQS(); $res = $sqs->create_queue(URL_QUEUE); if ($res->isOK()) { $queueURL = urlFromQueueObject($res); } // Load each URL for ($i = 1; $i < $argc; $i++) { // Create message $histItem = array('Posted by ' . $argv[0] . ' at ' . date('c')); $message = json_encode(array('Action' => 'FetchPage', 'Origin' => $argv[0], 'Data' => $argv[$i], 'History' => $histItem)); // Post message $res = $sqs->send_message($queueURL, $message); if ($res->isOK()) { print "Posted '{$message}' to queue " . URL_QUEUE . "\n"; } else { $error = $res->body->Error->Message;
public static function setAsideCron() { self::echomsg(null, "Start Sudarshan Stock Sync - SetAside", true); $sqs = new AmazonSQS(); $sqs->set_region(AmazonSQS::REGION_APAC_SE1); $db = Db::getInstance(_PS_USE_SQL_SLAVE_); $updates = false; while (true) { $response = $sqs->receive_message(STOCK_SYNC_QUEUE); if (!$response->body->ReceiveMessageResult->Message) { break; } else { $updates = true; self::echomsg(null, "--------------------------------------------------", true); $message = Tools::jsonDecode($response->body->ReceiveMessageResult->Message->Body, true); $supplier_reference = $message['supplier_reference']; $sup_details = explode("::", $supplier_reference); if (count($sup_details) !== 2) { self::echomsg($message, "Action Needed - Invalid Vendor Code. Manual SetAside needed", true); } else { $design_no = $sup_details[0]; $item_code = $sup_details[1]; $id_product = $message["id_product"]; $reference = $message["reference"]; $id_order = $message["id_order"]; $quantity = (int) $message["quantity"]; $product = array(); $product['id_product'] = $id_product; $product['reference'] = $reference; $product['supplier_reference'] = $supplier_reference; $product['id_order'] = $id_order; self::echomsg($product, "Quantity #{$quantity} - Waiting for SetAside Update"); for ($i = 1; $i <= $quantity; $i++) { try { $client = self::getClient(); $data = array("Itemcode" => $item_code, "DesignNo" => $design_no, "OrderNo" => (string) $id_order, "Size" => "-"); $result = $client->SetAside($data); if ((int) $result->SetAsideResult === 1) { self::echomsg($product, "SetAside success", true); } else { self::echomsg($product, "Manual SetAside Action Needed - System SetAside Failed", true); } } catch (Exception $ex) { $ex_msg = $ex->getMessage(); if (stripos($ex_msg, "is insufficient for the requested quantity")) { self::echomsg($product, "<b>Out of Stock</b>", true); } else { self::send_tech_mail('Stock Sync Update SetAside', "Set Aside API Failed"); self::echomsg($product, "Manual SetAside Action Needed - System SetAside Failed", true); } } } } $handle = $response->body->ReceiveMessageResult->Message->ReceiptHandle; $sqs->delete_message(STOCK_SYNC_QUEUE, $handle); } } self::echomsg(null, "--------------------------------------------------", true); self::echomsg(null, "End Sudarshan Stock Sync - SetAside", true); if ($updates) { self::send_log_mail('Set Aside'); } return true; }
public static function GetInstance($AWSAccessKeyId, $AWSAccessKey) { self::$Instance = new AmazonSQS($AWSAccessKeyId, $AWSAccessKey); return self::$Instance; }
* * http://aws.amazon.com/apache2.0/ * * or in the "license.txt" file accompanying this file. This file is * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS * OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the * License. * * Modified by Jeffrey S. Haemer <*****@*****.**> */ error_reporting(E_ALL); require_once 'AWSSDKforPHP/sdk.class.php'; require_once 'include/book.inc.php'; // Create the feed queue, if necessary, and grab its URL $sqs = new AmazonSQS(); $res = $sqs->create_queue(FEED_QUEUE); if ($res->isOK()) { $feedQueueUrl = urlFromQueueObject($res); } // Make sure that at least one argument was given if ($argc < 2) { exit('Usage: ' . $argv[0] . " [URL] [-f FILE] ...\n"); } // Create the SQS access object $sqs = new AmazonSQS(); // Process each argument for ($i = 1; $i < $argc; $i++) { if ($argv[$i] == '-f') { $urls = file($argv[++$i]); foreach ($urls as $url) {
* specific language governing permissions and limitations under the * License. */ error_reporting(E_ALL); require_once 'sdk.class.php'; require_once 'include/book.inc.php'; // Define image layout constants define('BORDER_LEFT', 12); define('BORDER_RIGHT', 12); define('BORDER_TOP', 12); define('BORDER_BOTTOM', 12); define('IMAGES_ACROSS', 4); define('IMAGES_DOWN', 4); define('GAP_SIZE', 6); // Create the SQS and S3 access objects $sqs = new AmazonSQS(); $s3 = new AmazonS3(); // Get the queue URL $queueURL_Render = $sqs->create_queue(RENDER_QUEUE)->body->CreateQueueResult->QueueUrl; // Pull, process while (true) { // Pull the message from the queue $message = pullMessage($sqs, $queueURL_Render); if ($message != null) { // Extract message detail $messageDetail = $message['MessageDetail']; $receiptHandle = (string) $message['ReceiptHandle']; $imageKeys = $messageDetail['Data']; $pageTitle = $messageDetail['PageTitle']; print "Processing message with " . count($imageKeys) . " images:\n"; // Create destination image
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS * OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the * License. * * Modified by Jeffrey S. Haemer <*****@*****.**> */ error_reporting(E_ALL); require_once 'AWSSDKforPHP/sdk.class.php'; require_once 'include/book.inc.php'; if ($argc != 2) { exit("Usage: " . $argv[0] . " bucket name\n"); } $bucket = $argv[1] == '-' ? BOOK_BUCKET : $argv[1]; // Create the SQS and S3 access objects $sqs = new AmazonSQS(); $s3 = new AmazonS3(); // Convert the queuenames to URLs $res = $sqs->create_queue(URL_QUEUE); if ($res->isOK()) { $urlQueueURL = urlFromQueueObject($res); } $res = $sqs->create_queue(PARSE_QUEUE); if ($res->isOK()) { $parseQueueURL = urlFromQueueObject($res); } // Pull, process, post while (true) { // Pull the message from the queue $message = pullMessage($sqs, $urlQueueURL); if ($message != null) {
* Copyright 2009-2010 Amazon.com, Inc. or its affiliates. All Rights * Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You * may not use this file except in compliance with the License. A copy * of the License is located at * * http://aws.amazon.com/apache2.0/ * * or in the "license.txt" file accompanying this file. This file is * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS * OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the * License. */ error_reporting(E_ALL); require_once 'tarzan.class.php'; require_once 'book.php'; // Create the SQS access object $sqs = new AmazonSQS(); // Retrieve list of SQS queues $res = $sqs->list_queues(); if ($res->isOK()) { $queues = $res->body->ListQueuesResult->QueueUrl; for ($i = 0; $i < count($queues); $i++) { print $queues[$i] . "\n"; } } else { print "Could not retrieve list of SQS queues\n"; } exit(0);
$doQueue = false; // Check arguments and determine mode if ($argc != 2 || $argv[1] != '-f' && $argv[1] != '-q') { exit("Usage:\n" . $argv[0] . " -f\n" . $argv[0] . " -q\n"); } switch ($argv[1]) { case '-f': $doFile = true; break; case '-q': $doQueue = true; break; } // Create the SimpleDB and access objects $sdb = new AmazonSDB(); $sqs = new AmazonSQS(); // Create array of interesting fields at feed level $feedFields = array('link', 'title', 'pubdate', 'tagline', 'language', 'generator', 'description'); // Create array of interesting fields at item level $itemFields = array('guid', 'link', 'title', 'description'); // Create array of possible fields for item key, in descending order of preference $itemKeyFields = array('guid', 'link', 'title'); // Process file argument if ($doFile) { // Get list of feeds to process $urls = file(FEEDS); print "Begin processing " . count($urls) . " feeds\n"; foreach ($urls as $url) { $url = trim($url); if (updateFeed($sdb, $url)) { print $url . " - updated.\n";
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS * OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the * License. * * Modified by Jeffrey S. Haemer <*****@*****.**> */ error_reporting(E_ALL); require_once 'AWSSDKforPHP/sdk.class.php'; require_once 'include/book.inc.php'; if ($argc != 2) { exit("Usage: " . $argv[0] . " bucket name\n"); } $bucket = $argv[1] == '-' ? BOOK_BUCKET : $argv[1]; // Create the SQS and S3 access objects $sqs = new AmazonSQS(); $s3 = new AmazonS3(); // Convert the queuenames to URLs $res = $sqs->create_queue(IMAGE_QUEUE); if ($res->isOK()) { $imageQueueURL = urlFromQueueObject($res); } $res = $sqs->create_queue(RENDER_QUEUE); if ($res->isOK()) { $renderQueueURL = urlFromQueueObject($res); } // Pull, process, post while (true) { // Pull the message from the queue $message = pullMessage($sqs, $imageQueueURL); if ($message != null) {
* * or in the "license.txt" file accompanying this file. This file is * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS * OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the * License. */ error_reporting(E_ALL); require_once 'sdk.class.php'; require_once 'include/book.inc.php'; // Make sure that at least one argument was given if ($argc < 2) { exit('Usage: ' . $argv[0] . " [URL] [-f FILE] ...\n"); } // Create the SQS access object $sqs = new AmazonSQS(); // Get queue URL $queueURL = $sqs->create_queue(FEED_QUEUE)->body->CreateQueueResult->QueueUrl; // Process each argument for ($i = 1; $i < $argc; $i++) { if ($argv[$i] == '-f') { $urls = file($argv[++$i]); foreach ($urls as $url) { loadURL($sqs, $queueURL, trim($url)); } } else { loadURL($sqs, $queueURL, $argv[$i]); } } function loadURL($sqs, $queue, $url) {