AMQPConnection
PHP Manual

AMQPConnection::reconnect

(PECL amqp >= Unknown)

AMQPConnection::reconnectCloses any open connection and creates a new connection with the AMQP broker.

说明

public bool AMQPConnection::reconnect ( void )

This method will close any open connections and initiate a new connection with the AMQP broker.

参数

此函数没有参数。

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

Example #1 AMQPConnection::reconnect() example

<?php

/* Create a new connection */
$cnn = new AMQPConnection();

// set the login details
$cnn->setLogin('mylogin');
$cnn->setPassword('mypass');

$cnn->connect();

// do something interesting


// ensure we have a valid connection
if (!$cnn->reconnect()) {
    echo 
"Could not reconnect to server";
}

?>


AMQPConnection
PHP Manual