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


PHP AMQPConnection::close方法代码示例

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


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

示例1: close

 /**
  * Close the running connection
  */
 public function close()
 {
     if (null !== $this->connection && $this->connection->isConnected()) {
         $this->channel->close();
         $this->connection->close();
     }
 }
开发者ID:graphaware,项目名称:php-simplemq,代码行数:10,代码来源:AbstractRunner.php

示例2: tearDown

 public function tearDown()
 {
     if ($this->ch2) {
         $this->ch2->close();
     }
     if ($this->conn) {
         $this->conn->close();
     }
 }
开发者ID:vongrad,项目名称:loanbroker,代码行数:9,代码来源:Bug49Test.php

示例3: tearDown

 public function tearDown()
 {
     if ($this->ch) {
         $this->ch->exchange_delete($this->exchange_name);
         $this->ch->close();
     }
     if ($this->conn) {
         $this->conn->close();
     }
 }
开发者ID:adridev,项目名称:php-amqplib,代码行数:10,代码来源:Bug40Test.php

示例4: tearDown

 public function tearDown()
 {
     try {
         $this->object->deleteQueue('/', self::QUEUE_TEST_NAME);
     } catch (\Exception $e) {
     }
     try {
         $this->object->deleteExchange('/', self::EXCHANGE_TEST_NAME);
     } catch (\Exception $e) {
     }
     $this->channel->close();
     $this->conn->close();
 }
开发者ID:aashley,项目名称:RabbitMQ-Management-API-Client,代码行数:13,代码来源:APIClientTest.php

示例5: listen

 /**
  * Process incoming request to generate pdf invoices and send them through 
  * email.
  */
 public function listen()
 {
     $this->log->addInfo('Begin listen routine');
     $connection = new AMQPConnection('localhost', 5672, 'guest', 'guest');
     $channel = $connection->channel();
     $channel->queue_declare('invoice_queue', false, true, false, false);
     /**
      * don't dispatch a new message to a worker until it has processed and 
      * acknowledged the previous one. Instead, it will dispatch it to the 
      * next worker that is not still busy.
      */
     $channel->basic_qos(null, 1, null);
     /**
      * indicate interest in consuming messages from a particular queue. When they do 
      * so, we say that they register a consumer or, simply put, subscribe to a queue.
      * Each consumer (subscription) has an identifier called a consumer tag
      */
     $channel->basic_consume('invoice_queue', '', false, false, false, false, array($this, 'process'));
     $this->log->addInfo('Consuming from queue');
     while (count($channel->callbacks)) {
         $this->log->addInfo('Waiting for incoming messages');
         $channel->wait();
     }
     $channel->close();
     $connection->close();
 }
开发者ID:aslijiasheng,项目名称:SPRabbitMQ,代码行数:30,代码来源:WorkerReceiver.php

示例6: processvideo

 function processvideo()
 {
     $this->load->config('amqp');
     $exchange = 'video';
     $queue = 'video_q';
     $consumer_tag = 'consumer';
     $connection = new AMQPConnection($this->config->item('host'), $this->config->item('port'), $channel = $this->config->item('user'), $channel = $this->config->item('pass'), "/");
     $channel = $connection->channel();
     $channel->queue_declare($queue, false, true, false, false);
     $callback = function ($msg) {
         print_r($msg);
         die;
         $collection = $this->mongo_db->db->selectCollection('video');
         $result = $collection->update(["video_id" => $msg->video_id], ["status" => "processing"]);
         sleep(range(5, 10));
         $start_date = new DateTime('2000-01-01 ' . $msg->start_time);
         $since_start = $start_date->diff(new DateTime('2012-09-11 ' . $msg->end_time));
         $video_len = $since_start->h . ":" . $since_start->i . ":" . $since_start->s;
         $result = $collection->update(["video_id" => $msg->video_id], ["status" => "done", "link" => "https://youtube.com?dffd", "video_len" => $video_len]);
         $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
     };
     $channel->basic_qos(null, 1, null);
     $channel->basic_consume($queue, '', false, false, false, false, $callback);
     while (count($channel->callbacks)) {
         $channel->wait();
     }
     $channel->close();
     $connection->close();
 }
开发者ID:Toilon,项目名称:test,代码行数:29,代码来源:Worker.php

示例7: actionIndex

 public function actionIndex()
 {
     Yii::info('Started email task', __METHOD__);
     $this->setupConnection();
     echo '[*] Waiting for messages. To exit press CTRL+C', "\n";
     $this->channel->basic_qos(null, 1, null);
     $this->channel->basic_consume($this->queue, '', false, false, false, false, [$this, 'processEmail']);
     while (count($this->channel->callbacks)) {
         $this->channel->wait();
     }
     echo 'Shutting down...', "\n";
     Yii::info('Shutting down...', __METHOD__);
     Yii::trace('Disconnecting...', __METHOD__);
     $this->channel->close();
     $this->connection->close();
     return self::EXIT_CODE_NORMAL;
 }
开发者ID:highestgoodlikewater,项目名称:yii2-mailqueue,代码行数:17,代码来源:EmailTaskController.php

示例8: disconnect

 public function disconnect()
 {
     if ($this->isConnected()) {
         $this->channel->close();
         $this->connection->close();
         $this->logger->info("Mq Service Disconnected");
     }
 }
开发者ID:danielsan80,项目名称:async-task,代码行数:8,代码来源:RabbitMqService.php

示例9: sendMessage

 /**
  * @inherit
  */
 public function sendMessage()
 {
     $msg = new AMQPMessage($this->data, $this->messageProperties);
     $this->channel->basic_publish($msg, $this->publishExchange, $this->publishRoutingKey, $this->publishMandatory, $this->publishImmediate, $this->publishTicket);
     $this->channel->close();
     $this->connection->close();
     return true;
 }
开发者ID:highestgoodlikewater,项目名称:yii2-mailqueue,代码行数:11,代码来源:RabbitMessage.php

示例10: close

 /**
  * Close the connection with the RabbitMQ server
  *
  * @return void
  */
 public function close()
 {
     if (isset($this->AMQPConnection)) {
         $this->AMQPConnection->close();
     }
     if (isset($this->channel)) {
         $this->channel->close();
     }
 }
开发者ID:bschmitt,项目名称:tail,代码行数:14,代码来源:Connection.php

示例11: shutdown

 /**
  */
 public function shutdown()
 {
     if ($this->channel) {
         $this->channel->close();
     }
     if ($this->connection) {
         $this->connection->close();
     }
 }
开发者ID:Neodork,项目名称:SonataNotificationBundle,代码行数:11,代码来源:AMQPBackendDispatcher.php

示例12: close

 public function close()
 {
     if ($this->channel != null) {
         $this->channel->close();
     }
     if ($this->connection != null) {
         $this->connection->close();
     }
 }
开发者ID:artox-lab,项目名称:rabbitmq-wrapper,代码行数:9,代码来源:RabbitMQ.php

示例13: execute

 /**
  * Sends an invoice generation task to the workers
  * 
  * @param int $invoiceNum
  */
 public function execute($invoiceNum)
 {
     $connection = new AMQPConnection('localhost', 5672, 'guest', 'guest');
     $channel = $connection->channel();
     $channel->queue_declare('invoice_queue', false, true, false, false);
     $msg = new AMQPMessage($invoiceNum, array('delivery_mode' => 2));
     $channel->basic_publish($msg, '', 'invoice_queue');
     $channel->close();
     $connection->close();
 }
开发者ID:corner82,项目名称:RabbitMQ_SanalFabrika,代码行数:15,代码来源:testWorkerSender.php

示例14: execute

 public static function execute($entry)
 {
     if (!empty($entry)) {
         $connection = new AMQPConnection('impact.ccat.eu', 5672, 'myjar', 'myjar');
         $channel = $connection->channel();
         $msg = new AMQPMessage($entry, array('content_type' => 'application/json'));
         $channel->basic_publish($msg, '', 'solved-interest-queue');
         $channel->close();
         $connection->close();
     }
 }
开发者ID:KristjanLuik,项目名称:queue_test_task,代码行数:11,代码来源:InterestBroadcaster.php

示例15: send

 function send($nachricht)
 {
     $connection = new AMQPConnection('141.22.29.97', 5672, 'invoiceSender', 'invoiceSender');
     $channel = $connection->channel();
     $channel->queue_declare('controllerInvoice', false, false, false, false);
     settype($nachricht, "string");
     $msg = new AMQPMessage($nachricht);
     $channel->basic_publish($msg, '', 'controllerInvoice');
     $channel->close();
     $connection->close();
 }
开发者ID:biggtfish,项目名称:invoiceNinja-1,代码行数:11,代码来源:send.php


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