class AMQPChannel (View source)

stub class representing AMQPChannel from pecl-amqp

Methods

void
commitTransaction()

Commit a pending transaction.

__construct(AMQPConnection $amqp_connection)

Create an instance of an AMQPChannel object.

bool
isConnected()

Check the channel connection.

void
close()

Closes the channel.

int
getChannelId()

Return internal channel ID

void
qos(int $size, int $count, bool $global = false)

Set the Quality Of Service settings for the given channel.

void
rollbackTransaction()

Rollback a transaction.

void
setPrefetchCount(int $count)

Set the number of messages to prefetch from the broker for each consumer.

int
getPrefetchCount()

Get the number of messages to prefetch from the broker for each consumer.

void
setPrefetchSize(int $size)

Set the window size to prefetch from the broker for each consumer.

int
getPrefetchSize()

Get the window size to prefetch from the broker for each consumer.

void
setGlobalPrefetchCount(int $count)

Set the number of messages to prefetch from the broker across all consumers.

int
getGlobalPrefetchCount()

Get the number of messages to prefetch from the broker across all consumers.

void
setGlobalPrefetchSize(int $size)

Set the window size to prefetch from the broker for all consumers.

int
getGlobalPrefetchSize()

Get the window size to prefetch from the broker for all consumers.

void
startTransaction()

Start a transaction.

getConnection()

Get the AMQPConnection object in use

void
basicRecover(bool $requeue = true)

Redeliver unacknowledged messages.

void
confirmSelect()

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

void
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).

void
waitForConfirm(float $timeout = 0.0)

Wait until all messages published since the last call have been either ack'd or nack'd by the broker.

void
setReturnCallback(callable $return_callback = null)

Set callback to process basic.return AMQP server method

void
waitForBasicReturn(float $timeout = 0.0)

Start wait loop for basic.return AMQP server methods

getConsumers()

Return array of current consumers where key is consumer and value is AMQPQueue consumer is running on

Details

void commitTransaction()

Commit a pending transaction.

Return Value

void

Exceptions

AMQPChannelException
AMQPConnectionException

__construct(AMQPConnection $amqp_connection)

Create an instance of an AMQPChannel object.

Parameters

AMQPConnection $amqp_connection

An instance of AMQPConnection with an active connection to a broker.

Exceptions

AMQPConnectionException

bool isConnected()

Check the channel connection.

Return Value

bool

Indicates whether the channel is connected.

void close()

Closes the channel.

Return Value

void

int getChannelId()

Return internal channel ID

Return Value

int

void qos(int $size, int $count, bool $global = false)

Set the Quality Of Service settings for the given channel.

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.

Parameters

int $size

The window size, in octets, to prefetch.

int $count

The number of messages to prefetch.

bool $global

TRUE for global, FALSE for consumer. FALSE by default.

Return Value

void

Exceptions

AMQPConnectionException

void rollbackTransaction()

Rollback a transaction.

Rollback an existing transaction. AMQPChannel::startTransaction() must be called prior to this.

Return Value

void

Exceptions

AMQPChannelException
AMQPConnectionException

void setPrefetchCount(int $count)

Set the number of messages to prefetch from the broker for each consumer.

Set the number of messages to prefetch from the broker during a call to AMQPQueue::consume() or AMQPQueue::get().

Parameters

int $count

The number of messages to prefetch.

Return Value

void

Exceptions

AMQPConnectionException

int getPrefetchCount()

Get the number of messages to prefetch from the broker for each consumer.

Return Value

int

void setPrefetchSize(int $size)

Set the window size to prefetch from the broker for each consumer.

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.

Parameters

int $size

The window size, in octets, to prefetch.

Return Value

void

Exceptions

AMQPConnectionException

int getPrefetchSize()

Get the window size to prefetch from the broker for each consumer.

Return Value

int

void setGlobalPrefetchCount(int $count)

Set the number of messages to prefetch from the broker across all consumers.

Set the number of messages to prefetch from the broker during a call to AMQPQueue::consume() or AMQPQueue::get().

Parameters

int $count

The number of messages to prefetch.

Return Value

void

Exceptions

AMQPConnectionException

int getGlobalPrefetchCount()

Get the number of messages to prefetch from the broker across all consumers.

Return Value

int

void setGlobalPrefetchSize(int $size)

Set the window size to prefetch from the broker for all consumers.

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.

Parameters

int $size

The window size, in octets, to prefetch.

Return Value

void

Exceptions

AMQPConnectionException

int getGlobalPrefetchSize()

Get the window size to prefetch from the broker for all consumers.

Return Value

int

void startTransaction()

Start a transaction.

This method must be called on the given channel prior to calling AMQPChannel::commitTransaction() or AMQPChannel::rollbackTransaction().

Return Value

void

Exceptions

AMQPConnectionException

AMQPConnection getConnection()

Get the AMQPConnection object in use

Return Value

AMQPConnection

void basicRecover(bool $requeue = true)

Redeliver unacknowledged messages.

Parameters

bool $requeue

Return Value

void

void confirmSelect()

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

Return Value

void

void 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).

Parameters

callable $ack_callback
callable $nack_callback

Callback functions with all arguments have the following signature:

 function ack_callback(int $deliveryTag, bool $multiple) : bool;
 function nack_callback(int $deliveryTag, 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).

Return Value

void

void waitForConfirm(float $timeout = 0.0)

Wait until all messages published since the last call have been either ack'd or nack'd by the broker.

Note, this method also catch all basic.return message from server.

Parameters

float $timeout

Timeout in seconds. May be fractional.

Return Value

void

Exceptions

AMQPQueueException

void setReturnCallback(callable $return_callback = null)

Set callback to process basic.return AMQP server method

Parameters

callable $return_callback

Callback function with all arguments has the following signature:

 function callback(int $reply_code,
                   string $reply_text,
                   string $exchange,
                   string $routingKey,
                   AMQPBasicProperties $properties,
                   string $body) : bool;

and should return boolean false when wait loop should be canceled.

Return Value

void

void waitForBasicReturn(float $timeout = 0.0)

Start wait loop for basic.return AMQP server methods

Parameters

float $timeout

Timeout in seconds. May be fractional.

Return Value

void

Exceptions

AMQPQueueException

AMQPQueue[] getConsumers()

Return array of current consumers where key is consumer and value is AMQPQueue consumer is running on

Return Value

AMQPQueue[]