original_string: public function subscribe($topicQueueName, callable $handler)
      {
          $isSubscriptionLoopActive = true;
          while ($isSubscriptionLoopActive) {
              $request = new SubscribeMessageRequest([
                  'queueName'          => $topicQueueName,
                  'pollingWaitSeconds' => 0,
              ]);
  
              try {
                  $message = $this->client->send($request);
              } catch (RequestException $e) {
                  throw $e;
              } catch (ResponseException $e) {
                  $message = $e->getBody();
  
                  if (!$message->has('code')) {
                      throw $e;
                  } else if (!in_array($message->get('code'), ['7000', '6070'])) {    // 队列没有消息或队列中有太多不可见或者延时消息
                      throw $e;
                  }
              } catch (\Exception $e) {
                  throw $e;
              }
  
              if ($message === null || $message->get('msgBody') === null) {
                  sleep(mt_rand(1, 5));
                  continue;
              }
  
              call_user_func($handler,
                  Utils::unserializeMessagePayload($message->get('msgBody')),
                  new MessageHandler($this->client, $topicQueueName, $message)
              );
  
              unset($message);
          }
      }
code: public function subscribe($topicQueueName, callable $handler)
      {
          $isSubscriptionLoopActive = true;
          while ($isSubscriptionLoopActive) {
              $request = new SubscribeMessageRequest([
                  'queueName'          => $topicQueueName,
                  'pollingWaitSeconds' => 0,
              ]);
  
              try {
                  $message = $this->client->send($request);
              } catch (RequestException $e) {
                  throw $e;
              } catch (ResponseException $e) {
                  $message = $e->getBody();
  
                  if (!$message->has('code')) {
                      throw $e;
                  } else if (!in_array($message->get('code'), ['7000', '6070'])) {    // 队列没有消息或队列中有太多不可见或者延时消息
                      throw $e;
                  }
              } catch (\Exception $e) {
                  throw $e;
              }
  
              if ($message === null || $message->get('msgBody') === null) {
                  sleep(mt_rand(1, 5));
                  continue;
              }
  
              call_user_func($handler,
                  Utils::unserializeMessagePayload($message->get('msgBody')),
                  new MessageHandler($this->client, $topicQueueName, $message)
              );
  
              unset($message);
          }
      }
code_tokens: public function subscribe ( $ topicQueueName , callable $ handler ) { $ isSubscriptionLoopActive = true ; while ( $ isSubscriptionLoopActive ) { $ request = new SubscribeMessageRequest ( [ 'queueName' => $ topicQueueName , 'pollingWaitSeconds' => 0 , ] ) ; try { $ message = $ this -> client -> send ( $ request ) ; } catch ( RequestException $ e ) { throw $ e ; } catch ( ResponseException $ e ) { $ message = $ e -> getBody ( ) ; if ( ! $ message -> has ( 'code' ) ) { throw $ e ; } else if ( ! in_array ( $ message -> get ( 'code' ) , [ '7000' , '6070' ] ) ) { // 队列没有消息或队列中有太多不可见或者延时消息 throw $ e ; } } catch ( \ Exception $ e ) { throw $ e ; } if ( $ message === null || $ message -> get ( 'msgBody' ) === null ) { sleep ( mt_rand ( 1 , 5 ) ) ; continue ; } call_user_func ( $ handler , Utils :: unserializeMessagePayload ( $ message -> get ( 'msgBody' ) ) , new MessageHandler ( $ this -> client , $ topicQueueName , $ message ) ) ; unset ( $ message ) ; } }
docstring: Subscribe a handler to a topic queue.
  
  @param string   $topicQueueName
  @param callable $handler
  @throws RequestException
  @throws ResponseException
  @throws \Exception
docstring_tokens: Subscribe a handler to a topic queue .