PHP Class AMQPChannel

显示文件 Open project: pdezwart/php-amqp Class Usage Examples

Public Methods

Method Description
__construct ( AMQPConnection $amqp_connection ) Create an instance of an AMQPChannel object.
basicRecover ( boolean $requeue = true ) Redeliver unacknowledged messages.
close ( ) Closes the channel.
commitTransaction ( ) : boolean Commit a pending transaction.
confirmSelect ( ) Set the channel to use publisher acknowledgements. This can only used on a non-transactional channel.
getChannelId ( ) : integer Return internal channel ID
getConnection ( ) : AMQPConnection Get the AMQPConnection object in use
getPrefetchCount ( ) : integer Get the number of messages to prefetch from the broker.
getPrefetchSize ( ) : integer Get the window size to prefetch from the broker.
isConnected ( ) : boolean Check the channel connection.
qos ( integer $size, integer $count ) : boolean Set the Quality Of Service settings for the given channel.
rollbackTransaction ( ) : boolean Rollback a transaction.
setConfirmCallback ( callable $ack_callback = null, callable $nack_callback = null ) Set callback to process basic.ack and basic.nac AMQP server methods (applicable when channel in confirm mode).
setPrefetchCount ( integer $count ) : boolean Set the number of messages to prefetch from the broker.
setPrefetchSize ( integer $size ) : boolean Set the window size to prefetch from the broker.
setReturnCallback ( callable $return_callback = null ) Set callback to process basic.return AMQP server method
startTransaction ( ) : boolean Start a transaction.
waitForBasicReturn ( float $timeout ) Start wait loop for basic.return AMQP server methods
waitForConfirm ( float $timeout ) Wait until all messages published since the last call have been either ack'd or nack'd by the broker.

Method Details

__construct() public method

Create an instance of an AMQPChannel object.
public __construct ( AMQPConnection $amqp_connection )
$amqp_connection AMQPConnection An instance of AMQPConnection with an active connection to a broker.

basicRecover() public method

Redeliver unacknowledged messages.
public basicRecover ( boolean $requeue = true )
$requeue boolean

close() public method

Closes the channel.
public close ( )

commitTransaction() public method

Commit a pending transaction.
public commitTransaction ( ) : boolean
return boolean TRUE on success or FALSE on failure.

confirmSelect() public method

Set the channel to use publisher acknowledgements. This can only used on a non-transactional channel.
public confirmSelect ( )

getChannelId() public method

Return internal channel ID
public getChannelId ( ) : integer
return integer

getConnection() public method

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

getPrefetchCount() public method

Get the number of messages to prefetch from the broker.
public getPrefetchCount ( ) : integer
return integer

getPrefetchSize() public method

Get the window size to prefetch from the broker.
public getPrefetchSize ( ) : integer
return integer

isConnected() public method

Check the channel connection.
public isConnected ( ) : boolean
return boolean Indicates whether the channel is connected.

qos() public method

Specify the amount of data to prefetch in terms of window size (octets) or number of messages from a queue during a AMQPQueue::consume() or AMQPQueue::get() method call. The client will prefetch data up to size octets or count messages from the server, whichever limit is hit first. Setting either value to 0 will instruct the client to ignore that particular setting. A call to AMQPChannel::qos() will overwrite any values set by calling AMQPChannel::setPrefetchSize() and AMQPChannel::setPrefetchCount(). If the call to either AMQPQueue::consume() or AMQPQueue::get() is done with the AMQP_AUTOACK flag set, the client will not do any prefetching of data, regardless of the QOS settings.
public qos ( integer $size, integer $count ) : boolean
$size integer The window size, in octets, to prefetch.
$count integer The number of messages to prefetch.
return boolean TRUE on success or FALSE on failure.

rollbackTransaction() public method

Rollback an existing transaction. AMQPChannel::startTransaction() must be called prior to this.
public rollbackTransaction ( ) : boolean
return boolean TRUE on success or FALSE on failure.

setConfirmCallback() public method

Set callback to process basic.ack and basic.nac AMQP server methods (applicable when channel in confirm mode).
public setConfirmCallback ( callable $ack_callback = null, callable $nack_callback = null )
$ack_callback callable
$nack_callback callable Callback functions with all arguments have the following signature: function ack_callback(int $delivery_tag, bool $multiple) : bool; function nack_callback(int $delivery_tag, bool $multiple, bool $requeue) : bool; and should return boolean false when wait loop should be canceled. Note, basic.nack server method will only be delivered if an internal error occurs in the Erlang process responsible for a queue (see https://www.rabbitmq.com/confirms.html for details).

setPrefetchCount() public method

Set the number of messages to prefetch from the broker during a call to AMQPQueue::consume() or AMQPQueue::get(). Any call to this method will automatically set the prefetch window size to 0, meaning that the prefetch window size setting will be ignored.
public setPrefetchCount ( integer $count ) : boolean
$count integer The number of messages to prefetch.
return boolean TRUE on success or FALSE on failure.

setPrefetchSize() public method

Set the prefetch window size, in octets, during a call to AMQPQueue::consume() or AMQPQueue::get(). Any call to this method will automatically set the prefetch message count to 0, meaning that the prefetch message count setting will be ignored. If the call to either AMQPQueue::consume() or AMQPQueue::get() is done with the AMQP_AUTOACK flag set, this setting will be ignored.
public setPrefetchSize ( integer $size ) : boolean
$size integer The window size, in octets, to prefetch.
return boolean TRUE on success or FALSE on failure.

setReturnCallback() public method

Set callback to process basic.return AMQP server method
public setReturnCallback ( callable $return_callback = null )
$return_callback callable Callback function with all arguments has the following signature: function callback(int $reply_code, string $reply_text, string $exchange, string $routing_key, AMQPBasicProperties $properties, string $body) : bool; and should return boolean false when wait loop should be canceled.

startTransaction() public method

This method must be called on the given channel prior to calling AMQPChannel::commitTransaction() or AMQPChannel::rollbackTransaction().
public startTransaction ( ) : boolean
return boolean TRUE on success or FALSE on failure.

waitForBasicReturn() public method

Start wait loop for basic.return AMQP server methods
public waitForBasicReturn ( float $timeout )
$timeout float Timeout in seconds. May be fractional.

waitForConfirm() public method

Note, this method also catch all basic.return message from server.
public waitForConfirm ( float $timeout )
$timeout float Timeout in seconds. May be fractional.