Exemplo n.º 1
0
<?php

#require("phar://iron_mq.phar");
require __DIR__ . '/vendor/autoload.php';
$ironmq = new \IronMQ\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";
print_r($res);
Exemplo n.º 2
0
<?php

#require("phar://iron_mq.phar");
require __DIR__ . '/vendor/autoload.php';
$ironmq = new \IronMQ\IronMQ();
#$ironmq->debug_enabled = true;
$ironmq->ssl_verifypeer = false;
for ($i = 0; $i < 10; $i++) {
    echo "Post message:\n";
    $res = $ironmq->postMessage("test_queue", "Test Message {$i}");
    var_dump($res);
    echo "Post messages:\n";
    $res = $ironmq->postMessages("test-queue-multi", array("Test Message {$i}", "Test Message {$i}-2"));
    var_dump($res);
    echo "Get message..\n";
    $message = $ironmq->getMessage("test_queue");
    print_r($message);
    echo "Touch message..\n";
    $res = $ironmq->touchMessage("test_queue", $message->id);
    print_r($res);
    echo "Release message..\n";
    $res = $ironmq->releaseMessage("test_queue", $message->id);
    print_r($res);
    echo "Peek message..\n";
    $res = $ironmq->peekMessage("test_queue");
    print_r($res);
    echo "Delete message..\n";
    $message = $ironmq->deleteMessage("test_queue", $message->id);
    print_r($message);
    $message = $ironmq->getMessage("test_queue");
    print_r($message);