本文整理汇总了PHP中AMQPQueue::purge方法的典型用法代码示例。如果您正苦于以下问题:PHP AMQPQueue::purge方法的具体用法?PHP AMQPQueue::purge怎么用?PHP AMQPQueue::purge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AMQPQueue
的用法示例。
在下文中一共展示了AMQPQueue::purge方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: purge
/**
* @return bool
*/
public function purge()
{
try {
return $this->rawQueue->purge();
} catch (\Exception $e) {
ClientHelper::throwRightException($e);
}
}
示例2: Run
public function Run()
{
// Declare a new exchange
$ex = new AMQPExchange($this->cnn);
$ex->declare('game', AMQP_EX_TYPE_TOPIC);
// Create a new queue
$q1 = new AMQPQueue($this->cnn);
$q1->declare('queue1');
$q1->purge('queue1');
$q2 = new AMQPQueue($this->cnn);
$q2->declare('queue2');
$q1->purge('queue2');
$q3 = new AMQPQueue($this->cnn);
$q3->declare('queue3');
$q3->purge('queue3');
$options = array('min' => 0, 'max' => 10, 'ack' => true);
// Bind it on the exchange to routing.key
$ex->bind('queue1', 'game1.#');
$ex->bind('queue2', 'game1.#');
$ex->bind('queue3', 'game1.#');
$ex->bind('queue3', 'queue3.#');
$msgbody1 = 'hello';
// Publish a message to the exchange with a routing key
$result = $ex->publish($msgbody1, 'game1.msg');
$this->AssertEquals($result, TRUE, 'publish message failed');
$msgbody2 = 'world';
// Publish a message to the exchange with a routing key
$result = $ex->publish($msgbody2, 'game1.msg');
$this->AssertEquals($result, TRUE, 'publish message failed');
$msgbody3 = 'hello player3';
// Publish a message to the exchange with a routing key
$result = $ex->publish($msgbody3, 'queue3.command');
$this->AssertEquals($result, TRUE, 'publish message failed');
// Read from the queue
$msg = $q1->consume($options);
$this->AddMessage(var_export($msg, true));
$this->AssertEquals(count($msg), 2);
$this->AssertEquals($msg[0]['message_body'], $msgbody1, 'message not equal');
$this->AssertEquals($msg[1]['message_body'], $msgbody2, 'message not equal');
// Read from the queue
$msg = $q2->consume($options);
$this->AssertEquals(count($msg), 2);
$this->AssertEquals($msg[0]['message_body'], $msgbody1, 'message not equal');
$this->AssertEquals($msg[1]['message_body'], $msgbody2, 'message not equal');
// Read from the queue
$msg = $q3->consume($options);
$this->AddMessage(var_export($msg, true));
$this->AssertEquals(count($msg), 3);
$this->AssertEquals($msg[0]['message_body'], $msgbody1, 'message not equal');
$this->AssertEquals($msg[1]['message_body'], $msgbody2, 'message not equal');
$this->AssertEquals($msg[2]['message_body'], $msgbody3, 'message not equal');
$msg = $q3->consume($options);
$this->AssertEquals(count($msg), 0);
}
示例3: Run
public function Run()
{
// Declare a new exchange
$ex = new AMQPExchange($this->cnn);
$ex->declare('game', AMQP_EX_TYPE_HEADER);
// Create a new queue
$q1 = new AMQPQueue($this->cnn);
$q1->declare('queue1');
$q1->purge('queue1');
$q2 = new AMQPQueue($this->cnn);
$q2->declare('queue2');
$q1->purge('queue2');
$q3 = new AMQPQueue($this->cnn);
$q3->declare('queue3');
$q3->purge('queue3');
$options = array('min' => 0, 'max' => 10, 'ack' => true);
// Bind it on the exchange to routing.key
$ex->bind('queue1', 'broadcast=1,target=1,x-match=any');
$ex->bind('queue2', 'broadcast=1,target=2,x-match=any');
$ex->bind('queue3', 'broadcast=1,target=3,x-match=any');
$msgbody1 = 'hello';
// Publish a message to the exchange with a routing key
$result = $ex->publish($msgbody1, NULL, AMQP_IMMEDIATE, array('headers' => array('broadcast' => 1)));
$this->AssertEquals($result, TRUE, 'publish message failed');
$msgbody2 = 'world';
// Publish a message to the exchange with a routing key
$result = $ex->publish($msgbody2, NULL, AMQP_IMMEDIATE, array('headers' => array('broadcast' => 1)));
$this->AssertEquals($result, TRUE, 'publish message failed');
$msgbody3 = 'queue3';
// Publish a message to the exchange with a routing key
$result = $ex->publish($msgbody1, NULL, AMQP_IMMEDIATE, array('headers' => array('target' => 3)));
$this->AssertEquals($result, TRUE, 'publish message failed');
// Read from the queue
$msg = $q1->consume($options);
$this->AddMessage(var_export($msg, true));
$this->AssertEquals(count($msg), 2);
//$this->AssertEquals($msg[0]['message_body'], $msgbody1, 'message not equal');
//$this->AssertEquals($msg[1]['message_body'], $msgbody2, 'message not equal');
// Read from the queue
$msg = $q2->consume($options);
$this->AssertEquals(count($msg), 2);
//$this->AssertEquals($msg[0]['message_body'], $msgbody1, 'message not equal');
//$this->AssertEquals($msg[1]['message_body'], $msgbody2, 'message not equal');
// Read from the queue
$msg = $q3->consume($options);
$this->AssertEquals(count($msg), 3);
//$this->AssertEquals($msg[0]['message_body'], $msgbody1, 'message not equal');
//$this->AssertEquals($msg[1]['message_body'], $msgbody2, 'message not equal');
//$this->AssertEquals($msg[2]['message_body'], $msgbody3, 'message not equal');
}
示例4: Run
public function Run()
{
// Create a new queue
$q1 = new AMQPQueue($this->cnn);
$q1->declare('queue1');
$q1->purge('queue1');
$options = array('min' => 0, 'max' => 10, 'ack' => true);
// Bind it on the exchange to routing.key
$q1->bind(\Constant\AMQPChannelConstant::AMF, \Constant\AMQPCommand::BingoBroadcast);
// Read from the queue
while (TRUE) {
$msg = $q1->consume($options);
var_dump($msg);
}
}
示例5: purge
/**
* @inheritdoc
*/
public function purge()
{
$this->queue->purge();
}
示例6: getEntityLink
$sdkBlockingTask = $service->createSDKObj($blockingTaskUrl);
// create a parameter for action on the blocking task
$params = new VMware_VCloud_API_Extension_BlockingTaskOperationParamsType();
$params->setMessage($message);
// a message for action reason
try {
// take a resume/abort/fail action on the blocking task
$sdkBlockingTask->{$action}($params);
echo "Action {$action} finished\n";
break;
} catch (Exception $e) {
echo $e->getMessage() . "\n";
continue;
// if failed, continue listening
}
$q->purge($queue);
// optionally, purge the contents in the queue
}
}
}
}
// end of while loop
//$q->delete($queue); // optionally, delete queue and its contents.
$conn->disconnect();
// disconnect from the AMQP broker.
} else {
echo "\n\nLogin Failed due to certification mismatch.";
return;
}
function getEntityLink($rel, $obj, $method = 'getEntityLink')
{
示例7: purge
/**
* @inheritdoc
*/
public function purge()
{
$this->delegate->purge();
}