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.
Exemplo n.º 1
0
 /**
  * @inheritdoc
  */
 public function basicQos($prefetchSize, $prefetchCount)
 {
     try {
         return $this->delegate->qos($prefetchSize, $prefetchCount);
     } catch (\AMQPChannelException $e) {
         throw new ChannelException($e->getMessage(), $e->getCode(), $e);
     } catch (\AMQPConnectionException $e) {
         throw new ConnectionException($e->getMessage(), $e->getCode(), $e);
     }
 }
Exemplo n.º 2
0
 /**
  * @param $size
  * @param $count
  *
  * @return bool
  */
 public function qos($size, $count)
 {
     try {
         return $this->rawChannel->qos($size, $count);
     } catch (\AMQPConnectionException $e) {
         ClientHelper::throwRightException($e);
     }
 }
Exemplo n.º 3
0
 /**
  * @inheritdoc
  */
 public function qos(int $size, int $count)
 {
     $this->channel->qos($size, $count);
 }
Exemplo n.º 4
0
 * @author  yuansir <yuansir@live.cn/yuansir-web.com>
 */
$exchangeName = 'queues';
$queueName = 'task_queue';
$routeKey = 'task_queue';
$connection = new AMQPConnection(array('host' => '127.0.0.1', 'port' => '5672', 'vhost' => '/', 'login' => 'guest', 'password' => 'guest'));
$connection->connect() or die("Cannot connect to the broker!\n");
$channel = new AMQPChannel($connection);
$exchange = new AMQPExchange($channel);
$exchange->setName($exchangeName);
$exchange->setType(AMQP_EX_TYPE_DIRECT);
$exchange->declare();
$queue = new AMQPQueue($channel);
$queue->setName($queueName);
$queue->setFlags(AMQP_DURABLE);
$queue->declare();
$queue->bind($exchangeName, $routeKey);
var_dump('[*] Waiting for messages. To exit press CTRL+C');
while (TRUE) {
    $queue->consume('callback');
    $channel->qos(0, 5);
}
$connection->disconnect();
function callback($envelope, $queue)
{
    $msg = $envelope->getBody();
    var_dump(" [x] Received:" . $msg);
    sleep(substr_count($msg, '.'));
    echo "recevied end";
    $queue->ack($envelope->getDeliveryTag());
}
 /**
  * @param int $size
  * @param int $count
  * @param boolean $global
  *
  * @return mixed
  */
 public function basic_qos($size, $count, $global = null)
 {
     $this->channel->qos($size, $count);
 }