/** * {@inheritDoc} */ public function destroy() { // Catch `queue not found` exceptions, throw the rest. try { $this->ironmq->deleteQueue($this->getNameWithPrefix()); } catch (\Exception $e) { if (false !== strpos($e->getMessage(), "Queue not found")) { $this->log(400, "Queue did not exist"); } else { throw $e; } } $key = $this->getNameWithPrefix(); $this->cache->delete($key); $this->log(200, "Queue has been destroyed."); return true; }
* @link http://dev.iron.io/ * @license BSD License * @copyright Feel free to copy, steal, take credit for, or whatever you feel like doing with this code. ;) */ /** * For more information about push queues and subscribers, visit http://dev.iron.io/mq/reference/push_queues/ */ require_once __DIR__ . '/../vendor/autoload.php'; use IronMQ\IronMQ; $ironMQ = new IronMQ(); //$ironMQ->debug_enabled = true; $ironMQ->ssl_verifypeer = false; // Generating a random queue so we don't collide with any existing queues. Feel free to use a proper name $queueName = md5(rand() . time()); // We add a 'type' => 'multicast' to turn this into a push queue, and attach a single subscriber $queueOptions = array('message_expiration' => 3600, 'type' => 'multicast', 'push' => array('subscribers' => array(array('url' => 'http://domain0.com/endpoint', 'name' => 'Sub 0')))); $ironMQ->createQueue($queueName, $queueOptions); // Add a single subscriber $singleAddResponse = $ironMQ->addSubscriber($queueName, array('url' => 'http://domain.com/endpoint', 'name' => 'Sub 1')); var_dump($singleAddResponse); $subscribers = array(array('url' => 'http://domain2.com/endpoint', 'name' => 'Sub 4'), array('url' => 'http://domain3.com/endpoint', 'name' => 'Sub 3')); $multiAddResponse = $ironMQ->addSubscribers($queueName, $subscribers); var_dump($multiAddResponse); // Replace the list of subscribers. You can also replace multiple with IronMQ::replaceSubscribers() // THIS DOES NOT UPDATE, BUT REPLACE THE ENTIRE LIST. To update a URL, you will need to remove and re-add the subscriber $updateSingleResponse = $ironMQ->replaceSubscriber($queueName, array('url' => 'http://newdomain.com/endpoint', 'name' => 'Sub 1')); // Remove a subscriber $removeResponse = $ironMQ->removeSubscriber($queueName, array('name' => 'Sub 3')); // Clean up our tests $ironMQ->deleteQueue($queueName);
/** * PHP client for IronMQ * IronMQ is a scalable, reliable, high performance message queue in the cloud. * * @link https://github.com/iron-io/iron_mq_php * @link http://www.iron.io/products/mq * @link http://dev.iron.io/ * @license BSD License * @copyright Feel free to copy, steal, take credit for, or whatever you feel like doing with this code. ;) */ require_once __DIR__ . '/../vendor/autoload.php'; use IronMQ\IronMQ; $ironMQ = new IronMQ(); //$ironMQ->debug_enabled = true; $ironMQ->ssl_verifypeer = false; // Get a list of queues that are currently in our project $queues = $ironMQ->getQueues(); var_dump($queues); // Create a new queue $queueName = md5(rand() . time()); $result = $ironMQ->createQueue($queueName, array('message_expiration' => 3600)); var_dump($result); // Clear a queue of all it's messages, but do not delete the queue $result = $ironMQ->clearQueue($queueName); var_dump($result); $result = $ironMQ->updateQueue($queueName, array('message_expiration' => 3600 * 2)); var_dump($result); // Delete a queue $result = $ironMQ->deleteQueue($queueName); var_dump($result);
$ironMQ->ssl_verifypeer = false; // Generating a random queue so we don't collide with any existing queues. Feel free to use a proper name $queueName = md5(rand() . time()); $ironMQ->createQueue($queueName, array('message_expiration' => 3600)); // Generate a queue to hold the alerts that will be generated $alertQueueName = $queueName . '_alerts'; $ironMQ->createQueue($alertQueueName, array('message_expiration' => 3600)); // Every 200 messages, generate an alert $alert = array('type' => 'progressive', 'direction' => 'asc', 'trigger' => 200, 'queue' => $alertQueueName); $addResponse = $ironMQ->addAlerts($queueName, array($alert)); var_dump($addResponse); // Our Alert queue should be empty $messages = $ironMQ->peekMessage($alertQueueName); var_dump($messages); // Let's generate a bunch of messages to trigger an alert for ($i = 0; $i < 250; $i++) { $ironMQ->postMessage($queueName, 'Test Message' . $i); } // We should now have one $messages = $ironMQ->peekMessage($alertQueueName); var_dump($messages); // To get the existing alerts on a queue, use getQueue() $queueData = $ironMQ->getQueue($queueName); $alerts = $queueData->alerts; // Update the alerts on a queue $alerts[0]->trigger = 500; $updateResponse = $ironMQ->updateAlerts($queueName, $alerts); var_dump($updateResponse); // Clean up our tests $ironMQ->deleteQueue($queueName); $ironMQ->deleteQueue($alertQueueName);