当前位置: 首页>>代码示例>>PHP>>正文


PHP AMQPQueue::get方法代码示例

本文整理汇总了PHP中AMQPQueue::get方法的典型用法代码示例。如果您正苦于以下问题:PHP AMQPQueue::get方法的具体用法?PHP AMQPQueue::get怎么用?PHP AMQPQueue::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AMQPQueue的用法示例。


在下文中一共展示了AMQPQueue::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get

 /**
  * {@inheritDoc}
  */
 public function get()
 {
     $envelope = $this->queue->get();
     if (!$envelope) {
         return;
     }
     return new Message($envelope->getBody(), array('content_type' => $envelope->getContentType(), 'routing_key' => $envelope->getRoutingKey(), 'delivery_tag' => $envelope->getDeliveryTag(), 'delivery_mode' => $envelope->getDeliveryMode(), 'exchange_name' => $envelope->getExchangeName(), 'is_redelivery' => $envelope->isRedelivery(), 'content_encoding' => $envelope->getContentEncoding(), 'type' => $envelope->getType(), 'timestamp' => $envelope->getTimeStamp(), 'priority' => $envelope->getPriority(), 'expiration' => $envelope->getExpiration(), 'app_id' => $envelope->getAppId(), 'message_id' => $envelope->getMessageId(), 'reply_to' => $envelope->getReplyTo(), 'correlation_id' => $envelope->getCorrelationId(), 'headers' => $envelope->getHeaders(), 'user_id' => $envelope->getUserId(), 'cluster_id' => 0, 'channel' => '', 'consumer_tag' => ''), $envelope->getDeliveryTag());
 }
开发者ID:kyar,项目名称:swarrot,代码行数:11,代码来源:PeclPackageMessageProvider.php

示例2: get

 /**
  * @inheritdoc
  */
 public function get($flags = null)
 {
     if (false !== ($envelope = $this->delegate->get(self::convertToDelegateFlags($flags)))) {
         $envelope = new Envelope($envelope);
     }
     return $envelope;
 }
开发者ID:treehouselabs,项目名称:queue,代码行数:10,代码来源:Queue.php

示例3: get

 /**
  * @inheritdoc
  */
 public function get(int $flags = Constants::AMQP_NOPARAM)
 {
     $envelope = $this->queue->get($flags);
     if ($envelope instanceof \AMQPEnvelope) {
         $envelope = new Envelope($envelope);
     }
     return $envelope;
 }
开发者ID:prolic,项目名称:HumusAmqp,代码行数:11,代码来源:Queue.php

示例4: read

 /**
  * @param \AMQPQueue $queue
  * @return bool|string
  */
 public static function read(\AMQPQueue $queue)
 {
     usleep(10000);
     $envelope = $queue->get(\AMQP_NOPARAM);
     if ($envelope) {
         $message = $envelope->getBody();
         $queue->ack($envelope->getDeliveryTag());
         return $message;
     }
     return false;
 }
开发者ID:zarincheg,项目名称:celium,代码行数:15,代码来源:Rabbit.php

示例5: take

 public function take()
 {
     $q = new \AMQPQueue($this->amqpChannel);
     $q->setName($this->name);
     $msg = $q->get();
     if (empty($msg)) {
         return false;
     } else {
         return new MessageTakeControl($q, $msg);
     }
 }
开发者ID:xezzus,项目名称:amqp-im,代码行数:11,代码来源:Message.php

示例6: get

 /**
  * @param int $flags
  *
  * @return Envelope|bool
  */
 public function get($flags = Client::NOPARAM)
 {
     try {
         $message = $this->rawQueue->get($flags);
         if ($message instanceof \AMQPEnvelope) {
             $message = Envelope::createFromRaw($message, $this->decodeStrategy);
         }
         return $message;
     } catch (\Exception $e) {
         ClientHelper::throwRightException($e);
     }
 }
开发者ID:csharpru,项目名称:yii2-amqp,代码行数:17,代码来源:Queue.php

示例7: execute

 /**
  * {@inheritDoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln(sprintf('Get %d messages from queue "%s"', $input->getOption('nb-messages'), $input->getArgument('queue')));
     $fromChannel = $this->getChannel($input->getArgument('connection'), $input->getArgument('vhost'));
     $queue = new \AMQPQueue($fromChannel);
     $queue->setName($input->getArgument('queue'));
     $noRequeue = $input->getOption('no-requeue');
     $nbMessages = $input->getOption('nb-messages');
     for ($i = 0; $i < $nbMessages; $i++) {
         if ($noRequeue) {
             $message = $queue->get(AMQP_AUTOACK);
         } else {
             $message = $queue->get();
         }
         if (false === $message) {
             $output->writeln('No more messages in queue.');
             return;
         }
         $output->writeln(print_r($message, true));
     }
 }
开发者ID:ikwattro,项目名称:rabbit-mq-admin-toolkit,代码行数:24,代码来源:MessageGetCommand.php

示例8: getProxy

 public function getProxy($https = false)
 {
     if ($https) {
         $queueName = 'q_proxy_https';
     } else {
         $queueName = 'q_proxy';
     }
     $params = array('host' => '10.168.45.191', 'port' => 5672, 'login' => 'guest', 'password' => 'guest', 'vhost' => '/kwd');
     $conn = new AMQPConnection($params);
     $conn->connect();
     $channel = new AMQPChannel($conn);
     $queue = new AMQPQueue($channel);
     $queue->setName($queueName);
     $message = $queue->get(AMQP_AUTOACK);
     $proxy = $message->getBody();
     while (!$this->_testProxy($proxy, $https)) {
         $message = $queue->get(AMQP_AUTOACK);
         $proxy = $message->getBody();
     }
     $conn->disconnect();
     return $proxy;
 }
开发者ID:ttian20,项目名称:crazyclick,代码行数:22,代码来源:class.proxy.php

示例9: readQueue

 public function readQueue($q_name)
 {
     $q = new \AMQPQueue($this->channel);
     $q->setName($q_name);
     //$q->setFlags(AMQP_DURABLE);
     //$q->declare();
     //$q->bind('exchange', $bindingkey);
     //消息获取
     $messages = $q->get(AMQP_AUTOACK);
     if ($messages) {
         return $messages->getBody();
     } else {
         return false;
     }
 }
开发者ID:dormscript,项目名称:dataTransfer,代码行数:15,代码来源:RabbitMq.php

示例10: get

 /**
  * (non-PHPdoc)
  * @see ContentEngine\Request.QueueInterface::get()
  */
 public function get()
 {
     if (!isset($this->queue)) {
         throw new \Exception('No AMQP queue set.');
     }
     $envelope = $this->queue->get($this->flags);
     if (!$envelope) {
         return null;
     }
     // extract data
     $serial = $envelope->getBody();
     $item = $this->serialiser->unserialise($serial);
     $item['amqpDeliveryTag'] = $envelope->getDeliveryTag();
     $item['amqpMessageId'] = $envelop->getMessageId();
     return $item;
 }
开发者ID:goatherd,项目名称:content-engine,代码行数:20,代码来源:Amqp.php

示例11: GetMessageBody

 /**
  * Return result of task execution for $task_id
  * @param AMQPConnection $connection Connection object
  * @param string $task_id Celery task identifier
  * @param boolean $removeMessageFromQueue whether to remove message from queue
  * @return array array('body' => JSON-encoded message body, 'complete_result' => AMQPEnvelope object)
  * 			or false if result not ready yet
  */
 function GetMessageBody($connection, $task_id, $removeMessageFromQueue = true)
 {
     $this->Connect($connection);
     $ch = $connection->channel;
     $q = new AMQPQueue($ch);
     $q->setName($task_id);
     $q->setFlags(AMQP_AUTODELETE | AMQP_DURABLE);
     $q->declareQueue();
     try {
         $q->bind('celeryresults', $task_id);
     } catch (AMQPQueueException $e) {
         if ($removeMessageFromQueue) {
             $q->delete();
         }
         $connection->disconnect();
         return false;
     }
     $message = $q->get(AMQP_AUTOACK);
     if (!$message) {
         if ($removeMessageFromQueue) {
             $q->delete();
         }
         $connection->disconnect();
         return false;
     }
     if ($message->getContentType() != 'application/json') {
         if ($removeMessageFromQueue) {
             $q->delete();
         }
         $connection->disconnect();
         throw new CeleryException('Response was not encoded using JSON - found ' . $message->getContentType() . ' - check your CELERY_RESULT_SERIALIZER setting!');
     }
     if ($removeMessageFromQueue) {
         $q->delete();
     }
     $connection->disconnect();
     return array('complete_result' => $message, 'body' => $message->getBody());
 }
开发者ID:UGuarder,项目名称:celery-php,代码行数:46,代码来源:amqppeclconnector.php

示例12: getCompleteResult

 /**
  * Connect to queue, see if there's a result waiting for us
  * Private - to be used internally
  */
 private function getCompleteResult()
 {
     if ($this->complete_result) {
         return $this->complete_result;
     }
     $this->connection->connect();
     $ch = new AMQPChannel($this->connection);
     $q = new AMQPQueue($ch);
     $q->setName($this->task_id);
     $q->setFlags(AMQP_AUTODELETE);
     #		$q->setArgument('x-expires', 86400000);
     $q->declareQueue();
     try {
         $q->bind('celeryresults', $this->task_id);
     } catch (AMQPQueueException $e) {
         $q->delete();
         $this->connection->disconnect();
         return false;
     }
     $message = $q->get(AMQP_AUTOACK);
     if (!$message) {
         $q->delete();
         $this->connection->disconnect();
         return false;
     }
     $this->complete_result = $message;
     if ($message->getContentType() != 'application/json') {
         $q->delete();
         $this->connection->disconnect();
         throw new CeleryException('Response was not encoded using JSON - found ' . $message->getContentType() . ' - check your CELERY_RESULT_SERIALIZER setting!');
     }
     $this->body = json_decode($message->getBody());
     $q->delete();
     $this->connection->disconnect();
     return false;
 }
开发者ID:NaszvadiG,项目名称:cim-xa,代码行数:40,代码来源:asyncresult.php

示例13: AMQPConnection

$rabbit = new AMQPConnection(array('host' => '127.0.0.1', 'port' => '5672', 'login' => 'guest', 'password' => 'guest'));
$rabbit->connect();
$channel = new AMQPChannel($rabbit);
$queue = new AMQPExchange($channel);
$queue->setName('amq.direct');
/**
 * Добавляем очередь откуда будем брать страницы
 */
$q = new AMQPQueue($channel);
$q->setName('pages_to_scan');
$q->declare();
$q->bind('amq.direct', 'analyze_page');
/**
 * Обрабатываем пока в очереди не закончатся сообщения
 */
while (true) {
    $page = $q->get();
    if ($page) {
        $url = $page->getBody();
        echo "Parsing: {$url}\n";
        $analyzer = new PageAnalyzer($url);
        /**
         * Если страница еще не была проанализирована, обрабатываем и добавляем в индекс
         */
        $analyzer->analyze();
        $q->ack($page->getDeliveryTag());
    } else {
        sleep(1);
    }
}
$rabbit->disconnect();
开发者ID:stanislav-web,项目名称:phphighload.com,代码行数:31,代码来源:analyze_page.php

示例14: asyncRead

 /**
  * Асинхронное чтение ответов
  * @param string $transactionId
  * @param callable $callBack - Функция вызываемая для каждой строки.
  * Приимвет два параметра
  * \AMQPEnvelope $envelope
  * \AMQPQueue $queue
  * Чтобы подтвердить получение нужно вызвать метод $queue->ack($envelope->getDeliveryTag());
  * Чтобы перейти к следующему элементу без подтверждения получения нужно вызвать метод $queue->cancel($envelope->getDeliveryTag());
  * Если возвращает false, то передор возвращается.
  * @return \AMQPQueue - Возвращает очередь чтобы ее можно было удалить, если она уже не нужна
  * @throws \Exception
  */
 public function asyncRead($transactionId, $callBack)
 {
     if (!is_callable($callBack)) {
         throw new \Exception('Callback not callable');
     }
     $chanel = $this->amqp->newChannel();
     $queue = new \AMQPQueue($chanel);
     $queue->setName($transactionId);
     // Таким образом можно проверить существует ли очередь.
     // Если она не существует, то будет ошибка и нужно вернуть пустой ответ
     $queue->setFlags(AMQP_PASSIVE);
     try {
         $queue->declareQueue();
     } catch (\Exception $e) {
         return $queue;
     }
     /** @var \AMQPEnvelope $envelop */
     while ($envelop = $queue->get()) {
         if (call_user_func($callBack, $envelop, $queue) === false) {
             break;
         }
     }
     return $queue;
 }
开发者ID:andriell,项目名称:yii2-amqp,代码行数:37,代码来源:AmqpProducer.php

示例15: checkDelivery

 /**
  * Check delivered message from MQ
  * @param object $queue
  * @return array $queArray
  * @access public
  */
 public function checkDelivery(\AMQPQueue $queue)
 {
     $queArray = array();
     $queue->bind($this->exchangeOptions['name'], $this->queueOptions['routing_key']);
     while ($message = $queue->get()) {
         if ($message->isRedelivery()) {
             $queArray[] = $message->getDeliveryTag() . "=" . $message->getBody();
         }
     }
     return $queArray;
 }
开发者ID:ExSituMarketing,项目名称:EXS-silex-rabbitmq-provider,代码行数:17,代码来源:AmqpService.php


注:本文中的AMQPQueue::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。