PHP Class AMQPConnection

Mostrar archivo Open project: pdezwart/php-amqp Class Usage Examples

Public Methods

Method Description
__construct ( array $credentials = [] ) Create an instance of AMQPConnection.
connect ( ) : boolean Establish a transient connection with the AMQP broker.
disconnect ( ) : boolean Closes the transient connection with the AMQP broker.
getCACert ( ) : string Get path to the CA cert file in PEM format
getCert ( ) : string Get path to the client certificate in PEM format
getHeartbeatInterval ( ) : integer Get number of seconds between heartbeats of the connection in seconds.
getHost ( ) : string Get the configured host.
getKey ( ) : string Get path to the client key in PEM format
getLogin ( ) : string Get the configured login.
getMaxChannels ( ) : integer Get the maximum number of channels the connection can handle.
getMaxFrameSize ( ) : integer Get max supported frame size per connection in bytes.
getPassword ( ) : string Get the configured password.
getPort ( ) : integer Get the configured port.
getReadTimeout ( ) : float Get the configured interval of time to wait for income activity from AMQP broker
getTimeout ( ) : float Get the configured interval of time to wait for income activity from AMQP broker
getUsedChannels ( ) : integer Return last used channel id during current connection session.
getVerify ( ) : boolean Get whether peer verification enabled or disabled
getVhost ( ) : string Get the configured vhost.
getWriteTimeout ( ) : float Get the configured interval of time to wait for outcome activity to AMQP broker
isConnected ( ) : boolean Check whether the connection to the AMQP broker is still valid.
isPersistent ( ) : boolean Whether connection persistent.
pconnect ( ) : boolean Establish a persistent connection with the AMQP broker.
pdisconnect ( ) : boolean Closes a persistent connection with the AMQP broker.
preconnect ( ) : boolean Close any open persistent connections and initiate a new one with the AMQP broker.
reconnect ( ) : boolean Close any open transient connections and initiate a new one with the AMQP broker.
setCACert ( string $cacert ) Set path to the CA cert file in PEM format
setCert ( string $cert ) Set path to the client certificate in PEM format
setHost ( string $host ) : boolean Set the hostname used to connect to the AMQP broker.
setKey ( string $key ) Set path to the client key in PEM format
setLogin ( string $login ) : boolean Set the login string used to connect to the AMQP broker.
setPassword ( string $password ) : boolean Set the password string used to connect to the AMQP broker.
setPort ( integer $port ) : boolean Set the port used to connect to the AMQP broker.
setReadTimeout ( integer $timeout ) : boolean Sets the interval of time to wait for income activity from AMQP broker
setTimeout ( integer $timeout ) : boolean Sets the interval of time to wait for income activity from AMQP broker
setVerify ( boolean $verify ) Enable or disable peer verification
setVhost ( string $vhost ) : boolean Sets the virtual host to which to connect on the AMQP broker.
setWriteTimeout ( integer $timeout ) : boolean Sets the interval of time to wait for outcome activity to AMQP broker

Method Details

__construct() public method

Creates an AMQPConnection instance representing a connection to an AMQP broker. A connection will not be established until AMQPConnection::connect() is called. $credentials = array( 'host' => amqp.host The host to connect too. Note: Max 1024 characters. 'port' => amqp.port Port on the host. 'vhost' => amqp.vhost The virtual host on the host. Note: Max 128 characters. 'login' => amqp.login The login name to use. Note: Max 128 characters. 'password' => amqp.password Password. Note: Max 128 characters. 'read_timeout' => Timeout in for income activity. Note: 0 or greater seconds. May be fractional. 'write_timeout' => Timeout in for outcome activity. Note: 0 or greater seconds. May be fractional. 'connect_timeout' => Connection timeout. Note: 0 or greater seconds. May be fractional. Connection tuning options (see http://www.rabbitmq.com/amqp-0-9-1-reference.html#connection.tune for details): 'channel_max' => Specifies highest channel number that the server permits. 0 means standard extension limit (see PHP_AMQP_MAX_CHANNELS constant) 'frame_max' => The largest frame size that the server proposes for the connection, including frame header and end-byte. 0 means standard extension limit (depends on librabbimq default frame size limit) 'heartbeat' => The delay, in seconds, of the connection heartbeat that the server wants. 0 means the server does not want a heartbeat. Note, librabbitmq has limited heartbeat support, which means heartbeats checked only during blocking calls. TLS support (see https://www.rabbitmq.com/ssl.html for details): 'cacert' => Path to the CA cert file in PEM format.. 'cert' => Path to the client certificate in PEM foramt. 'key' => Path to the client key in PEM format. 'verify' => Enable or disable peer verification. If peer verification is enabled then the common name in the server certificate must match the server name. Peer verification is enabled by default. )
public __construct ( array $credentials = [] )
$credentials array Optional array of credential information for connecting to the AMQP broker.

connect() public method

This method will initiate a connection with the AMQP broker.
public connect ( ) : boolean
return boolean TRUE on success or throw an exception on failure.

disconnect() public method

This method will close an open connection with the AMQP broker.
public disconnect ( ) : boolean
return boolean true if connection was successfully closed, false otherwise.

getCACert() public method

Get path to the CA cert file in PEM format
public getCACert ( ) : string
return string

getCert() public method

Get path to the client certificate in PEM format
public getCert ( ) : string
return string

getHeartbeatInterval() public method

When connection is connected, effective connection value returned, which is normally the same as original correspondent value passed to constructor, otherwise original value passed to constructor returned.
public getHeartbeatInterval ( ) : integer
return integer

getHost() public method

Get the configured host.
public getHost ( ) : string
return string The configured hostname of the broker

getKey() public method

Get path to the client key in PEM format
public getKey ( ) : string
return string

getLogin() public method

Get the configured login.
public getLogin ( ) : string
return string The configured login as a string.

getMaxChannels() public method

When connection is connected, effective connection value returned, which is normally the same as original correspondent value passed to constructor, otherwise original value passed to constructor returned.
public getMaxChannels ( ) : integer
return integer

getMaxFrameSize() public method

When connection is connected, effective connection value returned, which is normally the same as original correspondent value passed to constructor, otherwise original value passed to constructor returned.
public getMaxFrameSize ( ) : integer
return integer

getPassword() public method

Get the configured password.
public getPassword ( ) : string
return string The configured password as a string.

getPort() public method

Get the configured port.
public getPort ( ) : integer
return integer The configured port as an integer.

getReadTimeout() public method

Get the configured interval of time to wait for income activity from AMQP broker
public getReadTimeout ( ) : float
return float

getTimeout() public method

Get the configured interval of time to wait for income activity from AMQP broker
Deprecation: use AMQPConnection::getReadTimout() instead
public getTimeout ( ) : float
return float

getUsedChannels() public method

Return last used channel id during current connection session.
public getUsedChannels ( ) : integer
return integer

getVerify() public method

Get whether peer verification enabled or disabled
public getVerify ( ) : boolean
return boolean

getVhost() public method

Get the configured vhost.
public getVhost ( ) : string
return string The configured virtual host as a string.

getWriteTimeout() public method

Get the configured interval of time to wait for outcome activity to AMQP broker
public getWriteTimeout ( ) : float
return float

isConnected() public method

It does so by checking the return status of the last connect-command.
public isConnected ( ) : boolean
return boolean True if connected, false otherwise.

isPersistent() public method

When connection is not connected, boolean false always returned
public isPersistent ( ) : boolean
return boolean

pconnect() public method

This method will initiate a connection with the AMQP broker or reuse an existing one if present.
public pconnect ( ) : boolean
return boolean TRUE on success or throws an exception on failure.

pdisconnect() public method

This method will close an open persistent connection with the AMQP broker.
public pdisconnect ( ) : boolean
return boolean true if connection was found and closed, false if no persistent connection with this host, port, vhost and login could be found,

preconnect() public method

Close any open persistent connections and initiate a new one with the AMQP broker.
public preconnect ( ) : boolean
return boolean TRUE on success or FALSE on failure.

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.

setCACert() public method

Set path to the CA cert file in PEM format
public setCACert ( string $cacert )
$cacert string

setCert() public method

Set path to the client certificate in PEM format
public setCert ( string $cert )
$cert string

setHost() public method

Set the hostname used to connect to the AMQP broker.
public setHost ( string $host ) : boolean
$host string The hostname of the AMQP broker.
return boolean TRUE on success or FALSE on failure.

setKey() public method

Set path to the client key in PEM format
public setKey ( string $key )
$key string

setLogin() public method

Set the login string used to connect to the AMQP broker.
public setLogin ( string $login ) : boolean
$login string The login string used to authenticate with the AMQP broker.
return boolean TRUE on success or FALSE on failure.

setPassword() public method

Set the password string used to connect to the AMQP broker.
public setPassword ( string $password ) : boolean
$password string The password string used to authenticate with the AMQP broker.
return boolean TRUE on success or FALSE on failure.

setPort() public method

Set the port used to connect to the AMQP broker.
public setPort ( integer $port ) : boolean
$port integer The port used to connect to the AMQP broker.
return boolean TRUE on success or FALSE on failure.

setReadTimeout() public method

Sets the interval of time to wait for income activity from AMQP broker
public setReadTimeout ( integer $timeout ) : boolean
$timeout integer
return boolean

setTimeout() public method

Sets the interval of time to wait for income activity from AMQP broker
Deprecation: use AMQPConnection::setReadTimout($timeout) instead
public setTimeout ( integer $timeout ) : boolean
$timeout integer
return boolean

setVerify() public method

Enable or disable peer verification
public setVerify ( boolean $verify )
$verify boolean

setVhost() public method

Sets the virtual host to which to connect on the AMQP broker.
public setVhost ( string $vhost ) : boolean
$vhost string The virtual host to use on the AMQP broker.
return boolean true on success or false on failure.

setWriteTimeout() public method

Sets the interval of time to wait for outcome activity to AMQP broker
public setWriteTimeout ( integer $timeout ) : boolean
$timeout integer
return boolean