本文整理汇总了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();
}
}
示例2: tearDown
public function tearDown()
{
if ($this->ch2) {
$this->ch2->close();
}
if ($this->conn) {
$this->conn->close();
}
}
示例3: tearDown
public function tearDown()
{
if ($this->ch) {
$this->ch->exchange_delete($this->exchange_name);
$this->ch->close();
}
if ($this->conn) {
$this->conn->close();
}
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}
示例8: disconnect
public function disconnect()
{
if ($this->isConnected()) {
$this->channel->close();
$this->connection->close();
$this->logger->info("Mq Service Disconnected");
}
}
示例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;
}
示例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();
}
}
示例11: shutdown
/**
*/
public function shutdown()
{
if ($this->channel) {
$this->channel->close();
}
if ($this->connection) {
$this->connection->close();
}
}
示例12: close
public function close()
{
if ($this->channel != null) {
$this->channel->close();
}
if ($this->connection != null) {
$this->connection->close();
}
}
示例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();
}
示例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();
}
}
示例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();
}