Exemple #1
0
 /**
  * QueueBrowser constructor.
  *
  * @param Client $client
  * @param string $destination
  * @param bool $stopOnEnd
  */
 public function __construct(Client $client, $destination, $stopOnEnd = true)
 {
     $this->stopOnEnd = $stopOnEnd;
     $this->client = $client;
     $this->stopOnEnd = $stopOnEnd;
     $this->subscription = new Subscription($destination, null, 'auto', IdGenerator::generateId());
 }
 /**
  * Init the transaction state.
  *
  * @param array $options
  */
 protected function initTransaction(array $options = [])
 {
     if (!isset($options['transactionId'])) {
         $this->transactionId = IdGenerator::generateId();
         $this->getClient()->sendFrame($this->getProtocol()->getBeginFrame($this->transactionId));
     } else {
         $this->transactionId = $options['transactionId'];
     }
 }
 /**
  * @inheritdoc
  */
 public function subscribe($destination, $selector, $ack, array $header = [])
 {
     $subscription = new Subscription($destination, $selector, $ack, IdGenerator::generateId(), $header);
     $this->getClient()->sendFrame($this->getProtocol()->getSubscribeFrame($subscription->getDestination(), $subscription->getSubscriptionId(), $subscription->getAck(), $subscription->getSelector())->addHeaders($header));
     $this->subscriptions[$subscription->getSubscriptionId()] = $subscription;
     return $subscription->getSubscriptionId();
 }