$peekMessagesResult = $queueRestProxy->peekMessages("myqueue", $message_options); $messages = $peekMessagesResult->getQueueMessages(); // View messages. $messageCount = count($messages); if($messageCount <= 0){ echo "There are no messages.<br />"; } else{ foreach($messages as $message) { echo "Peeked message:<br />"; echo "Message Id: ".$message->getMessageId()."<br />"; echo "Date: ".date_format($message->getInsertionDate(), 'Y-m-d')."<br />"; echo "Message text: ".$message->getMessageText()."<br /><br />"; } }
<?php require_once "WindowsAzure/WindowsAzure.php"; require_once 'PHPUnit\autoload.php'; use WindowsAzure\Common\ServicesBuilder; use WindowsAzure\Common\ServiceException; use WindowsAzure\Queue\Models\PeekMessagesOptions; // Create Connection String $connectionString = "DefaultEndpointsProtocol=http;AccountName=[yourAccount];AccountKey=[yourKey]"; // Create table REST proxy. $queueRestProxy = ServicesBuilder::getInstance()->createQueueService($connectionString); // OPTIONAL: Set peek message options. $message_options = new PeekMessagesOptions(); $message_options->setNumberOfMessages(1); // Default value is 1. try { $peekMessagesResult = $queueRestProxy->peekMessages("myqueue", $message_options); } catch(ServiceException $e){ // Handle exception based on error codes and messages. // Error codes and messages are here: // http://msdn.microsoft.com/en-us/library/windowsazure/dd179446.aspx $code = $e->getCode(); $error_message = $e->getMessage(); echo $code.": ".$error_message."<br />"; } $messages = $peekMessagesResult->getQueueMessages(); // View messages. $messageCount = count($messages); if($messageCount <= 0){ echo "There are no messages.<br />"; } else{ foreach($messages as $message) { echo "Peeked message:<br />"; echo "Message Id: ".$message->getMessageId()."<br />"; echo "Date: ".date_format($message->getInsertionDate(), 'Y-m-d')."<br />"; echo "Message text: ".$message->getMessageText()."<br /><br />"; } } ?>
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท