本文整理汇总了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();
}
}
示例2: tearDown
public function tearDown()
{
if ($this->channel) {
$this->channel->queue_delete($this->queueName . '1');
$this->channel->close();
}
if ($this->connection) {
$this->connection->close();
}
}
示例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();
}
示例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;
}
}
示例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();
}
示例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();
}
}
示例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();
}
示例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();
示例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();
示例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();
}