Пример #1
0
 /**
  * Creates PeekMessagesResult object from parsed XML response.
  *
  * @param array $parsedResponse XML response parsed into array.
  * 
  * @return WindowsAzure\Queue\Models\PeekMessagesResult.
  */
 public static function create($parsedResponse)
 {
     $result = new PeekMessagesResult();
     $queueMessages = array();
     if (!empty($parsedResponse)) {
         $rawMessages = Utilities::getArray($parsedResponse['QueueMessage']);
         foreach ($rawMessages as $value) {
             $message = WindowsAzureQueueMessage::createFromPeekMessages($value);
             $queueMessages[] = $message;
         }
     }
     $result->setQueueMessages($queueMessages);
     return $result;
 }
Пример #2
0
 /**
  * Retrieves a message from the front of the queue, without changing 
  * the message visibility.
  * 
  * @param string              $queueName The queue name.
  * @param PeekMessagesOptions $options   The optional parameters.
  * 
  * @return WindowsAzure\Common\Models\PeekMessagesResult
  */
 public function peekMessages($queueName, $options = null)
 {
     Validate::isString($queueName, 'queueName');
     Validate::notNullOrEmpty($queueName, 'queueName');
     $method = Resources::HTTP_GET;
     $headers = array();
     $queryParams = array();
     $postParams = array();
     $path = $queueName . '/messages';
     $statusCode = Resources::STATUS_OK;
     if (is_null($options)) {
         $options = new PeekMessagesOptions();
     }
     $messagesCount = $options->getNumberOfMessages();
     $timeout = $options->getTimeout();
     $this->addOptionalQueryParam($queryParams, Resources::QP_PEEK_ONLY, 'true');
     $this->addOptionalQueryParam($queryParams, Resources::QP_TIMEOUT, $timeout);
     $this->addOptionalQueryParam($queryParams, Resources::QP_NUM_OF_MESSAGES, $messagesCount);
     $response = $this->send($method, $headers, $queryParams, $postParams, $path, $statusCode);
     $parsed = $this->dataSerializer->unserialize($response->getBody());
     return PeekMessagesResult::create($parsed);
 }
 /**
  * @covers WindowsAzure\Queue\Models\PeekMessagesResult::setQueueMessages
  */
 public function testSetQueueMessages()
 {
     // Setup
     $sample = TestResources::listMessagesSample();
     $expectedMessageId = '1234b585-0ac3-4e2a-ad0c-18e3992brca1';
     $result = PeekMessagesResult::create($sample);
     $expected = $result->getQueueMessages();
     $expected[0]->setMessageId($expectedMessageId);
     // Test
     $result->setQueueMessages($expected);
     $this->assertEquals($expected, $result->getQueueMessages());
 }