downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

AMQPConnection::disconnect> <AMQPConnection::connect
[edit] Last updated: Wed, 19 Jun 2013

view this page in

AMQPConnection::__construct

(PECL amqp >= Unknown)

AMQPConnection::__constructCrear una instancia de Conexión de PCMA (AMQP)

Descripción

public AMQPConnection::__construct ([ array $credentials = array() ] )

Crear una instancia de AMQPConnection representando una conexión a un corredor PCMA (AMQP).

Parámetros

credentials

Las credentials es un arreglo opcional de la credencial para conectar al corredor PCMA (AMQP).

Índices disponibles
clave descripción valor por omisión
host Host al que conectar

Nota: Máximo 1024 caracteres

amqp.host
port Puerto del host amqp.port
vhost Host virtual del host

Nota: Máximo 128 caracteres

amqp.vhost
login Nombre de inicio de sesión.

Nota: Máximo 128 caracteres

amqp.login
password Contraseña

Nota: Máximo 128 caracteres

amqp.password

Cualquier otra clave será ignorada.

Valores devueltos

Un objeto AMQPConnection.

Errores/Excepciones

Lanza una AMQPException al fallar el análisis de los parámetros, y al producirse un error en las opciones.

Ejemplos

Ejemplo #1 Ejemplo de AMQPConnection::__construct()

<?php

/* Crea una conexión utilizando las credenciales por omisión: */
$connection1 = new AMQPConnection();

/* Y especificando todas las claves */
$connection2 = new AMQPConnection(array(
    
'host' => 'example.host',
    
'vhost' => '/',
    
'port' => 5763,
    
'login' => 'user',
    
'password' => 'password'
));

?>

Notas

Nota:

Una conexión no se establecerá hasta llamar a AMQPConnection::connect().



add a note add a note User Contributed Notes AMQPConnection::__construct - [2 notes]
up
0
pinepain at gmail dot com
5 months ago
It is not documented here, but additional key supported for AMQP

Version => 1.0.9
Revision => $Revision: 327551 $
AMQP protocol version => 0-9-1
librabbitmq version => 0.2.0

timeout     Timeout to wait for a new messages    float   amqp.timeout
up
0
bolo at nospam dot autistici dot org
1 year ago
A simply function that help manage connections to AMQP server.
It works fine in debian wheezy php 5.3.8.
Change Login & Password value at your plasure.
(Host will be the default value = 127.0.0.1).

<?php
function amqp_connection() {

   
$connection = new AMQPConnection();
   
$connection->setLogin('guest');
   
$connection->setPassword('guest');
   
$connection->connect();

    if (!
$connection->isConnected()) {
         echo
"Cannot connect to the broker";
    }
    return
$connection;
}

//Next manage the connection with $connection var

// function ...

// $connection=amqp_connection();

// ...
?>

 
show source | credits | sitemap | contact | advertising | mirror sites