reconnect() public method

Close any open transient connections and initiate a new one with the AMQP broker.
public reconnect ( ) : boolean
return boolean TRUE on success or FALSE on failure.
示例#1
0
 /**
  * @inheritdoc
  */
 public function reconnect() : bool
 {
     if ($this->options->getPersistent()) {
         return $this->connection->preconnect();
     } else {
         return $this->connection->reconnect();
     }
 }
示例#2
0
<?php

echo "<pre>";
$conn_args = array("host" => 'localhost', 'port' => 5672, 'login' => 'guest', "password" => 'guest', 'vhost' => '/');
$conn = new AMQPConnection($conn_args);
if ($conn->connect()) {
    echo "Success\r\n";
} else {
    echo "Fail\r\n";
}
//关闭连接重新连接
if (!$conn->reconnect()) {
    echo "Could not reconnect to server";
}
var_dump($conn);
示例#3
0
 /**
  * @inheritdoc
  */
 public function reconnect()
 {
     return $this->delegate->reconnect();
 }
示例#4
0
 public function reconnect()
 {
     try {
         $this->rawConnection->reconnect();
     } catch (\AMQPConnectionException $e) {
         ClientHelper::throwRightException($e);
     }
 }