本文整理汇总了PHP中PhpAmqpLib\Channel\AMQPChannel::wait方法的典型用法代码示例。如果您正苦于以下问题:PHP AMQPChannel::wait方法的具体用法?PHP AMQPChannel::wait怎么用?PHP AMQPChannel::wait使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhpAmqpLib\Channel\AMQPChannel
的用法示例。
在下文中一共展示了AMQPChannel::wait方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: waitingForCall
public function waitingForCall()
{
$this->channel->basic_consume(self::QUEUE_NAME, '', false, false, false, false, array($this, 'receive'));
while (count($this->channel->callbacks)) {
$this->channel->wait();
}
}
示例2: resolve
/**
* @param Invoker\Reply $reply
* @param float $timeout
*
* @return $this
*/
public function resolve(Invoker\Reply $reply, $timeout = null)
{
while (!empty($this->channel->callbacks) && !$this->isResolved($reply)) {
$this->channel->wait(null, true, $timeout);
}
return $this;
}
示例3: consume
public function consume(ConsumerInterface $consumer, $callback)
{
$this->channel->basic_consume($consumer->getName(), '', false, false, false, false, $callback);
while (count($this->channel->callbacks)) {
$this->channel->wait();
}
}
示例4: wait
public function wait()
{
// Loop as long as the channel has callbacks registered
while (count($this->channel->callbacks)) {
$this->channel->wait();
}
}
示例5: listen
/**
* Infinite loop: Listens for messages from the queue and sends them to the callback.
*
* @param callback $callback
*/
public function listen($callback)
{
$this->channel->basic_qos(null, 1, null);
$this->channel->basic_consume(self::QUEUE_NAME, '', false, true, false, false, $callback);
while ($this->channel->callbacks) {
$this->channel->wait();
}
}
示例6: consume
/**
* @param string $exchangeName
* @param callable $callback
*/
public function consume($exchangeName, callable $callback)
{
$this->callback = $callback;
$this->channel->basic_consume($exchangeName, '', false, true, false, false, [$this, 'callback']);
while (count($this->channel->callbacks)) {
$this->channel->wait();
}
}
示例7: consume
/**
* Consumes one event and calls callback for it.
*
* @param integer $timeout Optional timeout in seconds. Default is no timeout.
*
* @return void
*/
public function consume($timeout = 0)
{
try {
$this->channel->wait(null, false, $timeout);
} catch (AMQPTimeoutException $e) {
return;
}
}
示例8: listen
/**
* Listen declared queues
* @param null $cliMessage
*/
public function listen($cliMessage = null)
{
if (!empty($cliMessage)) {
echo $cliMessage;
}
while (count($this->channel->callbacks)) {
$this->channel->wait();
}
}
示例9: consume
public function consume()
{
$queue = $this->initialize();
$tag = $this->handler->name();
$this->channel->basic_consume($queue, $tag, false, false, false, false, [$this, 'handle']);
while (isset($this->channel->callbacks[$tag])) {
$this->channel->wait();
}
}
示例10: testPublishConsume
public function testPublishConsume()
{
$this->msg_body = 'foo bar baz äëïöü';
$msg = new AMQPMessage($this->msg_body, array('content_type' => 'text/plain', 'delivery_mode' => 1, 'correlation_id' => 'my_correlation_id', 'reply_to' => 'my_reply_to'));
$this->ch->basic_publish($msg, $this->exchange_name, $this->queue_name);
$this->ch->basic_consume($this->queue_name, getmypid(), false, false, false, false, array($this, 'process_msg'));
while (count($this->ch->callbacks)) {
$this->ch->wait();
}
}
示例11: testSendFile
public function testSendFile()
{
$this->msg_body = file_get_contents(__DIR__ . '/fixtures/data_1mb.bin');
$msg = new AMQPMessage($this->msg_body, array('delivery_mode' => 1));
$this->ch->basic_publish($msg, $this->exchange_name, $this->queue_name);
$this->ch->basic_consume($this->queue_name, '', false, false, false, false, array($this, 'process_msg'));
while (count($this->ch->callbacks)) {
$this->ch->wait();
}
}
示例12: consume
/**
* @param callable $callback
* @return void
*/
public function consume(callable $callback)
{
$internCallback = function ($msg) use($callback) {
//echo " [x] Received ", $msg->body, "\n";
$callback(unserialize($msg->body));
};
$this->exchange->basic_consume($this->exchangeName, '', false, true, false, false, $internCallback);
while (count($this->exchange->callbacks)) {
$this->exchange->wait();
}
}
示例13: call
/**
* @param $n
* @return int
*/
public function call($n)
{
$this->response = null;
$this->corr_id = uniqid();
$msg = new AMQPMessage((string) $n, ['correlation_id' => $this->corr_id, 'reply_to' => $this->callback_queue]);
$this->channel->basic_publish($msg, '', 'rpc_queue');
while (!$this->response) {
$this->channel->wait();
}
return intval($this->response);
}
示例14: consume
/**
* @param string $queue
* @param string $exchange
* @param string $routingKey
* @param callable $callback
*/
public function consume($queue, $exchange, $routingKey, $callback)
{
$this->declareComponents($routingKey, $exchange, $queue);
$this->channel->basic_consume($queue, '', false, false, false, false, function ($amqpMessage) use($callback) {
$message = new Message($amqpMessage);
$callback($message);
});
while (count($this->channel->callbacks)) {
$this->channel->wait();
}
}
示例15: wait
/**
* {@inheritdoc}
*/
public function wait(Closure $callback)
{
$this->channel->basic_consume($this->queue, '', false, true, false, false, function ($rabbitMessage) use($callback) {
$message = $this->serializer->unserialize($rabbitMessage->body);
$callback($message);
$rabbitMessage->delivery_info['channel']->basic_ack($rabbitMessage->delivery_info['delivery_tag']);
});
while (count($this->channel->callbacks)) {
$this->channel->wait();
}
}