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


PHP AMQPConnection::close方法代码示例

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


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

示例1: tearDown

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

示例2: tearDown

 public function tearDown()
 {
     if ($this->channel) {
         $this->channel->queue_delete($this->queueName . '1');
         $this->channel->close();
     }
     if ($this->connection) {
         $this->connection->close();
     }
 }
开发者ID:heristop,项目名称:HeriJobQueueBundle,代码行数:10,代码来源:AmqpAdapterTest.php

示例3: sendMessage

 private static function sendMessage($exchange, $data)
 {
     global $CC_CONFIG;
     $conn = new AMQPConnection($CC_CONFIG["rabbitmq"]["host"], $CC_CONFIG["rabbitmq"]["port"], $CC_CONFIG["rabbitmq"]["user"], $CC_CONFIG["rabbitmq"]["password"], $CC_CONFIG["rabbitmq"]["vhost"]);
     $channel = $conn->channel();
     $channel->access_request($CC_CONFIG["rabbitmq"]["vhost"], false, false, true, true);
     $channel->exchange_declare($exchange, 'direct', false, true);
     $msg = new AMQPMessage($data, array('content_type' => 'text/plain'));
     $channel->basic_publish($msg, $exchange);
     $channel->close();
     $conn->close();
 }
开发者ID:nidzix,项目名称:Airtime,代码行数:12,代码来源:RabbitMq.php

示例4: close

 public function close()
 {
     if ($this->closed != true) {
         if ($this->channel != null) {
             $this->channel->close();
             $this->channel = null;
         }
         if ($this->connection != null) {
             $this->connection->close();
             $this->connection = null;
         }
         $this->closed = true;
     }
 }
开发者ID:holdensmagicalunicorn,项目名称:skypebot,代码行数:14,代码来源:LoggerAppenderRabbitMQ.php

示例5: sendMessage

 private static function sendMessage($exchange, $data)
 {
     $CC_CONFIG = Config::getConfig();
     $conn = new AMQPConnection($CC_CONFIG["rabbitmq"]["host"], $CC_CONFIG["rabbitmq"]["port"], $CC_CONFIG["rabbitmq"]["user"], $CC_CONFIG["rabbitmq"]["password"], $CC_CONFIG["rabbitmq"]["vhost"]);
     if (!isset($conn)) {
         throw new Exception("Cannot connect to RabbitMQ server");
     }
     $channel = $conn->channel();
     $channel->access_request($CC_CONFIG["rabbitmq"]["vhost"], false, false, true, true);
     $channel->exchange_declare($exchange, 'direct', false, true);
     $msg = new AMQPMessage($data, array('content_type' => 'text/plain'));
     $channel->basic_publish($msg, $exchange);
     $channel->close();
     $conn->close();
 }
开发者ID:RadioCampusFrance,项目名称:airtime,代码行数:15,代码来源:RabbitMq.php

示例6: send

 function send($to, $subject, $text)
 {
     try {
         $conn = new AMQPConnection($this->rabbitMQConf['host'], $this->rabbitMQConf['port'], $this->rabbitMQConf['user'], $this->rabbitMQConf['pass']);
         $channel = $conn->channel();
         $channel->access_request($this->rabbitMQConf['virtualHost'], false, false, true, true);
         $mailData = array("to" => $to, "subject" => $subject, "text" => $text);
         $mailDataToJson = json_encode($mailData);
         $msg = new AMQPMessage($mailDataToJson, array('content_type' => 'text/plain'));
         $channel->basic_publish($msg, $this->queueConf['exchange']);
         $channel->close();
         $conn->close();
         return true;
     } catch (Exception $e) {
         echo "Something went wrong " . $e->getMessage();
     }
 }
开发者ID:flying5,项目名称:rabbitmq-examples,代码行数:17,代码来源:publisher.php

示例7: SendMessageToShowRecorder

 public static function SendMessageToShowRecorder($event_type)
 {
     global $CC_CONFIG;
     $conn = new AMQPConnection($CC_CONFIG["rabbitmq"]["host"], $CC_CONFIG["rabbitmq"]["port"], $CC_CONFIG["rabbitmq"]["user"], $CC_CONFIG["rabbitmq"]["password"]);
     $channel = $conn->channel();
     $channel->access_request($CC_CONFIG["rabbitmq"]["vhost"], false, false, true, true);
     $EXCHANGE = 'airtime-show-recorder';
     $channel->exchange_declare($EXCHANGE, 'direct', false, true);
     $today_timestamp = date("Y-m-d H:i:s");
     $now = new DateTime($today_timestamp);
     $end_timestamp = $now->add(new DateInterval("PT2H"));
     $end_timestamp = $end_timestamp->format("Y-m-d H:i:s");
     $temp['event_type'] = $event_type;
     if ($event_type = "update_schedule") {
         $temp['shows'] = Show::getShows($today_timestamp, $end_timestamp, $excludeInstance = NULL, $onlyRecord = TRUE);
     }
     $data = json_encode($temp);
     $msg = new AMQPMessage($data, array('content_type' => 'text/plain'));
     $channel->basic_publish($msg, $EXCHANGE);
     $channel->close();
     $conn->close();
 }
开发者ID:romansavrulin,项目名称:Airtime,代码行数:22,代码来源:RabbitMq.php

示例8: AMQPConnection

$queue = 'tweets';
$conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST);
$ch = $conn->channel();
/*
    The following code is the same both in the consumer and the producer.
    In this way we are sure we always have a queue to consume from and an
        exchange where to publish messages.
*/
/*
    name: $queue
    passive: false
    durable: true // the queue will survive server restarts
    exclusive: false // the queue can be accessed in other channels
    auto_delete: false //the queue won't be deleted once the channel is closed.
*/
$ch->queue_declare($queue, false, true, false, false);
/*
    name: $exchange
    type: direct
    passive: false
    durable: true // the exchange will survive server restarts
    auto_delete: false //the exchange won't be deleted once the channel is closed.
*/
$ch->exchange_declare($exchange, 'direct', false, true, false);
$ch->queue_bind($queue, $exchange);
$msg_body = implode(' ', array_slice($argv, 1));
$msg = new AMQPMessage($msg_body, array('content_type' => 'text/plain'));
$ch->basic_publish($msg, $exchange);
$ch->close();
$conn->close();
开发者ID:scumola,项目名称:rsshose.com,代码行数:30,代码来源:amqp_publisher.php

示例9: AMQPConnection

<?php

require_once __DIR__ . '/lib/php-amqplib/amqp.inc';
$connection = new AMQPConnection('localhost', 5672, 'guest', 'guest');
$channel = $connection->channel();
$channel->exchange_declare('logs', 'fanout', false, false, false);
$data = implode(' ', array_slice($argv, 1));
if (empty($data)) {
    $data = "info: Hello World!";
}
$msg = new AMQPMessage($data);
$channel->basic_publish($msg, 'logs');
echo " [x] Sent ", $data, "\n";
$channel->close();
$connection->close();
开发者ID:nivertech,项目名称:rabbitmq-tutorials,代码行数:15,代码来源:emit_log.php

示例10: queue

 public function queue($queue)
 {
     $connection = new AMQPConnection('localhost', 5672, 'guest', 'guest');
     $channel = $connection->channel();
     $channel->queue_declare('rockola', false, false, false, false);
     $msg = new AMQPMessage($queue);
     $channel->basic_publish($msg, '', 'rockola');
     $channel->close();
     $connection->close();
 }
开发者ID:albertorv,项目名称:Cyber_Rockola,代码行数:10,代码来源:TracksController.php


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