Exemplo n.º 1
0
 /**
  * Set the pre-fetch limits for this connection.
  *
  * @recoil-coroutine
  *
  * The pre-fetch count is the maximum number of unacknowledged messages that
  * are delivered to this connection.
  *
  * The pre-fetch limit is the maximum total size of unacknowledge messages
  * (in bytes) that is delivered to this connection.
  *
  * This feature is incompatible with the "per_consumer_qos" broker
  * capability.
  *
  * RabbitMQ does not support per-connection limits (current as of v3.5.6).
  *
  * @param int|null     $count   The pre-fetch count limit (null = unlimited).
  * @param int|null     $size    The pre-fetch size limit (null = unlimited).
  * @param Channel|null $channel The application-managed channel to use (null = auto-managed).
  *
  * @throws NotSupportedException The broker does not support this feature.
  * @throws ConnectionException   The connection is closed.
  */
 public function setQosLimits(int $count = null, int $size = null, Channel $channel = null) : Generator
 {
     assert($size === null || $size > 0);
     assert($count === null || $count > 0);
     if ($this->connectionManager === null) {
         throw SingleConnectionException::notOpen($this->options);
     } elseif ($this->features->perConsumerQos) {
         throw NotSupportedException::incompatibleCapability('per-connection QoS limits', 'per_consumer_qos');
     } elseif ($size !== null && !$this->features->qosSizeLimits) {
         throw NotSupportedException::unsupportedFeature('pre-fetch size limits');
     }
     $channelManager = (yield $this->connectionManager->acquireChannel($channel));
     try {
         (yield $channelManager->call(BasicQosFrame::create($size ?: 0, $count ?: 0, true), BasicQosOkFrame::METHOD_ID));
     } finally {
         if ($channel === null) {
             $channelManager->release();
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Set the pre-fetch limits for consumers on this channel.
  *
  * @recoil-coroutine
  *
  * Only consumers created after setting the limits are affected.
  *
  * The pre-fetch count is the maximum number of unacknowledged messages that
  * are delivered to each consumer on this channel.
  *
  * The pre-fetch limit is the maximum total size of unacknowledge messages
  * (in bytes) that is delivered to this channel.
  *
  * This feature requires the "per_consumer_qos" broker capability.
  *
  * RabbitMQ does not support pre-fetch size limits (current as of v3.5.6).
  *
  * @param int|null $count The pre-fetch count limit (null = unlimited).
  * @param int|null $size  The pre-fetch size limit (null = unlimited).
  *
  * @throws NotSupportedException The broker does not support this feature.
  * @throws ConnectionException   The connection is closed.
  * @throws ChannelException      The channel is closed.
  */
 public function setConsumerQosLimits(int $count = null, int $size = null) : Generator
 {
     assert($size === null || $size > 0);
     assert($count === null || $count > 0);
     if ($this->channelManager === null) {
         throw ChannelException::notOpen($this->channelId);
     } elseif (!$this->features->perConsumerQos) {
         throw NotSupportedException::missingCapability('per-consumer QoS limits', 'per_consumer_qos');
     } elseif ($size !== null && !$this->features->qosSizeLimits) {
         throw NotSupportedException::unsupportedFeature('pre-fetch size limits');
     }
     $this->channelManager->setDirty();
     (yield $this->channelManager->call(BasicQosFrame::create($size ?: 0, $count ?: 0, false), BasicQosOkFrame::METHOD_ID));
 }
Exemplo n.º 3
0
 /**
  * Set the pre-fetch limits for this consumer's auto-managed channel.
  *
  * @recoil-coroutine
  *
  * This feature can not be used if the consumer is using a channel managed
  * by the application.
  *
  * The consumer must be closed and reopened for the changes to take affect.
  *
  * The pre-fetch count is the maximum number of unacknowledged messages that
  * are delivered to this channel.
  *
  * The pre-fetch limit is the maximum total size of unacknowledged messages
  * (in bytes) that is delivered to this channel.
  *
  * RabbitMQ does not support pre-fetch size limits (current as of v3.5.6).
  *
  * @param int|null $count The pre-fetch count limit (null = unlimited).
  * @param int|null $size  The pre-fetch size limit (null = unlimited).
  */
 public function setQosLimits(int $count = null, int $size = null) : Generator
 {
     assert($size === null || $size > 0);
     assert($count === null || $count > 0);
     assert($this->channel === null, 'can not set QOS limits when using an application-managed channel');
     if ($size !== null && !$this->features->qosSizeLimits) {
         throw NotSupportedException::unsupportedFeature('pre-fetch size limits');
     }
     $this->preFetchCount = $count ?: 0;
     $this->preFetchSize = $size ?: 0;
     return;
     yield;
     // @codeCoverageIgnore
 }