Пример #1
0
 /**
  * @param AMQPReader $propertyReader
  * @param AMQPReader $contentReader
  * @return \PhpAmqpLib\Message\AMQPMessage
  */
 protected function createMessage($propertyReader, $contentReader)
 {
     $bodyChunks = array();
     $bodyReceivedBytes = 0;
     $message = new AMQPMessage();
     $message->load_properties($propertyReader)->setBodySize($contentReader->read_longlong());
     while (bccomp($message->getBodySize(), $bodyReceivedBytes, 0) == 1) {
         list($frame_type, $payload) = $this->next_frame();
         $this->validate_body_frame($frame_type);
         $bodyReceivedBytes = bcadd($bodyReceivedBytes, mb_strlen($payload, 'ASCII'), 0);
         if (is_int($this->maxBodySize) && $bodyReceivedBytes > $this->maxBodySize) {
             $message->setIsTruncated(true);
             continue;
         }
         $bodyChunks[] = $payload;
     }
     $message->setBody(implode('', $bodyChunks));
     $messageEncoding = $message->getContentEncoding();
     if ($this->auto_decode && !empty($messageEncoding)) {
         try {
             // Where does the decode() method come from if body is a string?
             $decodedBody = $message->getBody()->decode($messageEncoding);
             $message->setBody($decodedBody);
         } catch (\Exception $e) {
             $this->debug->debug_msg('Ignoring body decoding exception: ' . $e->getMessage());
         }
     }
     return $message;
 }
Пример #2
0
 /**
  * @param AMQPReader $propertyReader
  * @param AMQPReader $contentReader
  * @return \PhpAmqpLib\Message\AMQPMessage
  */
 protected function createMessage($propertyReader, $contentReader)
 {
     $bodyChunks = array();
     $bodyReceivedBytes = 0;
     $message = new AMQPMessage();
     $message->load_properties($propertyReader)->setBodySize($contentReader->read_longlong());
     while (bccomp($message->getBodySize(), $bodyReceivedBytes, 0) == 1) {
         list($frame_type, $payload) = $this->next_frame();
         $this->validate_body_frame($frame_type);
         $bodyReceivedBytes = bcadd($bodyReceivedBytes, mb_strlen($payload, 'ASCII'), 0);
         if (is_int($this->maxBodySize) && $bodyReceivedBytes > $this->maxBodySize) {
             $message->setIsTruncated(true);
             continue;
         }
         $bodyChunks[] = $payload;
     }
     $message->setBody(implode('', $bodyChunks));
     return $message;
 }