Exemplo n.º 1
0
 /**
  * Updates the queue object
  *
  * @param string $queue_name
  * @param array $options Parameters to change. keys:
  * - "subscribers" url's to subscribe to
  * - "push_type" multicast (default) or unicast.
  * - "retries" Number of retries. 3 by default
  * - "retries_delay" Delay between retries. 60 (seconds) by default
  * @throws CException
  */
 public function mqUpdateQueue($queue_name, $options)
 {
     try {
         return $this->_mq->updateQueue($queue_name, $options);
     } catch (Exception $e) {
         Yii::log('Error in IronMQ: ' . $e->getMessage(), 'error', 'ext.yiiron');
         throw new CException($e->getMessage());
     }
 }
<?php

#require("phar://iron_mq.phar");
require "../iron_core_php/IronCore.class.php";
require "IronMQ.class.php";
$ironmq = new IronMQ();
#$ironmq->debug_enabled = true;
$ironmq->ssl_verifypeer = false;
$queue_name = "push-queue-" . rand(0, 100);
$subscribers = array();
for ($i = 0; $i < 5; $i++) {
    $subscribers[$i] = array('url' => "http://rest-test.iron.io/code/200?store={$queue_name}-{$i}");
}
# enable push queue
$res = $ironmq->updateQueue($queue_name, array('subscribers' => $subscribers, 'push_type' => "unicast"));
#print_r($res);
$res = $ironmq->getQueue($queue_name);
echo "Queue enabled, " . count($res->subscribers) . " subscribers\n";
# Add one more subscriber
$res = $ironmq->addSubscriber($queue_name, array('url' => 'http://example.com'));
#print_r($res);
$res = $ironmq->getQueue($queue_name);
echo "Added subscriver, " . count($res->subscribers) . " subscribers\n";
$subscribers = $res->subscribers;
# Remove all subscribers
foreach ($subscribers as $subscriber) {
    echo "- " . $subscriber->url . "\n";
    $ironmq->removeSubscriber($queue_name, array('url' => $subscriber->url));
}
$res = $ironmq->getQueue($queue_name);
echo "Queue info:\n";
Exemplo n.º 3
0
$ironmq->clearQueue("test_queue");
$ironmq->postMessage("test_queue", "Test Message 1");
$ironmq->postMessage("test_queue", "Test Message 2");
$message = $ironmq->reserveMessage("test_queue");
$res = $ironmq->releaseMessage("test_queue", $message->id, 0, $message->reservation_id);
var_dump($res);
$ironmq->clearQueue("test_queue");
$res = $ironmq->getQueue("test_queue");
var_dump($res);
$ironmq->postMessage("test_queue_aler", "Test Message 1");
$res = $ironmq->getQueue("test_queue_aler");
var_dump($res);
$res = $ironmq->addAlerts("test_queue_aler", array(array('type' => 'progressive', 'direction' => 'asc', 'trigger' => 200, 'queue' => 'ddd')));
var_dump($res);
$res = $ironmq->getQueue("test_queue_aler");
var_dump($res);
$ironmq->postMessage("test_queue_upd", "Test Message 2");
$res = $ironmq->getQueue("test_queue_upd");
$res = $ironmq->updateQueue("test_queue_upd", array('message_expiration' => 600777));
var_dump($res);
$res = $ironmq->createQueue("test_queue_c", array('message_expiration' => 600333));
var_dump($res);
$ironmq->deleteQueue("test_queue_push");
$res = $ironmq->createQueue("test_queue_push", array('type' => 'multicast', 'push' => array('subscribers' => array(array('url' => 'http://localhost:3000/test', 'name' => 'subscriber_name')))));
var_dump($res);
$res = $ironmq->addSubscribers("test_queue_push", array(array('url' => 'http://localhost:3000/test2', 'name' => 'first'), array('url' => 'http://localhost:3000/test3', 'name' => 'second')));
var_dump($res);
$res = $ironmq->replaceSubscribers("test_queue_push", array(array('url' => 'https://first.replace.com', 'name' => 'replace.first'), array('url' => 'https://second.replace.com', 'name' => 'replace.second')));
var_dump($res);
$res = $ironmq->removeSubscriber("test_queue_push", array("name" => "replace.first"));
var_dump($ironmq->getQueue("test_queue_push"));