PHP Class AMQPExchange

Exibir arquivo Open project: pdezwart/php-amqp Class Usage Examples

Public Methods

Method Description
__construct ( AMQPChannel $amqp_channel ) Create an instance of AMQPExchange.
bind ( string $exchange_name, string $routing_key = '', array $arguments = [] ) : boolean Bind to another exchange.
declareExchange ( ) : boolean Declare a new exchange on the broker.
delete ( string $exchangeName = null, integer $flags = AMQP_NOPARAM ) : boolean Delete the exchange from the broker.
getArgument ( string $key ) : string | integer | boolean Get the argument associated with the given key.
getArguments ( ) : array Get all arguments set on the given exchange.
getChannel ( ) : AMQPChannel Get the AMQPChannel object in use
getConnection ( ) : AMQPConnection Get the AMQPConnection object in use
getFlags ( ) : integer Get all the flags currently set on the given exchange.
getName ( ) : string Get the configured name.
getType ( ) : string Get the configured type.
hasArgument ( string $key ) : boolean Check whether argument associated with the given key exists.
publish ( string $message, string $routing_key = null, integer $flags = AMQP_NOPARAM, array $attributes = [] ) : boolean Publish a message to an exchange.
setArgument ( string $key, string | integer $value ) : boolean Set the value for the given key.
setArguments ( array $arguments ) : boolean Set all arguments on the exchange.
setFlags ( integer $flags ) : void Set the flags on an exchange.
setName ( string $exchange_name ) : void Set the name of the exchange.
setType ( string $exchange_type ) : void Set the type of the exchange.
unbind ( string $exchange_name, string $routing_key = '', array $arguments = [] ) : boolean Remove binding to another exchange.

Method Details

__construct() public method

Returns a new instance of an AMQPExchange object, associated with the given AMQPChannel object.
public __construct ( AMQPChannel $amqp_channel )
$amqp_channel AMQPChannel A valid AMQPChannel object, connected to a broker.

bind() public method

Bind an exchange to another exchange using the specified routing key.
public bind ( string $exchange_name, string $routing_key = '', array $arguments = [] ) : boolean
$exchange_name string Name of the exchange to bind.
$routing_key string The routing key to use for binding.
$arguments array Additional binding arguments.
return boolean true on success or false on failure.

declareExchange() public method

Declare a new exchange on the broker.
public declareExchange ( ) : boolean
return boolean TRUE on success or FALSE on failure.

delete() public method

Delete the exchange from the broker.
public delete ( string $exchangeName = null, integer $flags = AMQP_NOPARAM ) : boolean
$exchangeName string Optional name of exchange to delete.
$flags integer Optionally AMQP_IFUNUSED can be specified to indicate the exchange should not be deleted until no clients are connected to it.
return boolean true on success or false on failure.

getArgument() public method

Get the argument associated with the given key.
public getArgument ( string $key ) : string | integer | boolean
$key string The key to look up.
return string | integer | boolean The string or integer value associated with the given key, or FALSE if the key is not set.

getArguments() public method

Get all arguments set on the given exchange.
public getArguments ( ) : array
return array An array containing all of the set key/value pairs.

getChannel() public method

Get the AMQPChannel object in use
public getChannel ( ) : AMQPChannel
return AMQPChannel

getConnection() public method

Get the AMQPConnection object in use
public getConnection ( ) : AMQPConnection
return AMQPConnection

getFlags() public method

Get all the flags currently set on the given exchange.
public getFlags ( ) : integer
return integer An integer bitmask of all the flags currently set on this exchange object.

getName() public method

Get the configured name.
public getName ( ) : string
return string The configured name as a string.

getType() public method

Get the configured type.
public getType ( ) : string
return string The configured type as a string.

hasArgument() public method

Check whether argument associated with the given key exists.
public hasArgument ( string $key ) : boolean
$key string The key to look up.
return boolean

publish() public method

Publish a message to the exchange represented by the AMQPExchange object.
public publish ( string $message, string $routing_key = null, integer $flags = AMQP_NOPARAM, array $attributes = [] ) : boolean
$message string The message to publish.
$routing_key string The optional routing key to which to publish to.
$flags integer One or more of AMQP_MANDATORY and AMQP_IMMEDIATE.
$attributes array One of content_type, content_encoding, message_id, user_id, app_id, delivery_mode, priority, timestamp, expiration, type or reply_to, headers.
return boolean TRUE on success or FALSE on failure.

setArgument() public method

Set the value for the given key.
public setArgument ( string $key, string | integer $value ) : boolean
$key string Name of the argument to set.
$value string | integer Value of the argument to set.
return boolean TRUE on success or FALSE on failure.

setArguments() public method

Set all arguments on the exchange.
public setArguments ( array $arguments ) : boolean
$arguments array An array of key/value pairs of arguments.
return boolean TRUE on success or FALSE on failure.

setFlags() public method

Set the flags on an exchange.
public setFlags ( integer $flags ) : void
$flags integer A bitmask of flags. This call currently only considers the following flags: AMQP_DURABLE, AMQP_PASSIVE (and AMQP_DURABLE, if librabbitmq version >= 0.5.3)
return void

setName() public method

Set the name of the exchange.
public setName ( string $exchange_name ) : void
$exchange_name string The name of the exchange to set as string.
return void

setType() public method

Set the type of the exchange. This can be any of AMQP_EX_TYPE_DIRECT, AMQP_EX_TYPE_FANOUT, AMQP_EX_TYPE_HEADERS or AMQP_EX_TYPE_TOPIC.
public setType ( string $exchange_type ) : void
$exchange_type string The type of exchange as a string.
return void

unbind() public method

Remove a routing key binding on an another exchange from the given exchange.
public unbind ( string $exchange_name, string $routing_key = '', array $arguments = [] ) : boolean
$exchange_name string Name of the exchange to bind.
$routing_key string The routing key to use for binding.
$arguments array Additional binding arguments.
return boolean true on success or false on failure.