src/ServiceBus/ServiceBusRestProxy.php
public function receiveMessage($path, ReceiveMessageOptions $receiveMessageOptions = null)
    {
        if (is_null($receiveMessageOptions)) {
            $receiveMessageOptions = new ReceiveMessageOptions();
        }

        $httpCallContext = new HttpCallContext();
        $httpCallContext->setPath($path);
        $httpCallContext->addStatusCode(Resources::STATUS_CREATED);
        $httpCallContext->addStatusCode(Resources::STATUS_NO_CONTENT);
        $httpCallContext->addStatusCode(Resources::STATUS_OK);
        $timeout = $receiveMessageOptions->getTimeout();
        if (!is_null($timeout)) {
            $httpCallContext->addQueryParameter('timeout', $timeout);
        }

        if ($receiveMessageOptions->getIsReceiveAndDelete()) {
            $httpCallContext->setMethod(Resources::HTTP_DELETE);
        } elseif ($receiveMessageOptions->getIsPeekLock()) {
            $httpCallContext->setMethod(Resources::HTTP_POST);
        } else {
            throw new \InvalidArgumentException(
                Resources::INVALID_RECEIVE_MODE_MSG
            );
        }

        $response = $this->sendHttpContext($httpCallContext);
        if ($response->getStatusCode() === Resources::STATUS_NO_CONTENT) {
            $brokeredMessage = null;
        } else {
            $responseHeaders = HttpClient::getResponseHeaders($response);

            $brokerProperties = new BrokerProperties();

            if (array_key_exists('brokerproperties', $responseHeaders)) {
                $brokerProperties = BrokerProperties::create($responseHeaders['brokerproperties']);
            }

            if (array_key_exists('location', $responseHeaders)) {
                $brokerProperties->setLockLocation($responseHeaders['location']);
            }

            $brokeredMessage = new BrokeredMessage();
            $brokeredMessage->setBrokerProperties($brokerProperties);

            if (array_key_exists(Resources::CONTENT_TYPE, $responseHeaders)) {
                $brokeredMessage->setContentType($responseHeaders[Resources::CONTENT_TYPE]);
            }

            if (array_key_exists('date', $responseHeaders)) {
                $brokeredMessage->setDate($responseHeaders['date']);
            }

            $brokeredMessage->setBody($response->getBody());

            foreach ($responseHeaders as $headerKey => $value) {
                $decodedValue = json_decode($value);
                if (is_scalar($decodedValue)) {
                    $brokeredMessage->setProperty(
                        $headerKey,
                        $decodedValue
                    );
                }
            }
        }

        return $brokeredMessage;
    }
public function receiveMessage($path, ReceiveMessageOptions $receiveMessageOptions = null)
    {
        if (is_null($receiveMessageOptions)) {
            $receiveMessageOptions = new ReceiveMessageOptions();
        }

        $httpCallContext = new HttpCallContext();
        $httpCallContext->setPath($path);
        $httpCallContext->addStatusCode(Resources::STATUS_CREATED);
        $httpCallContext->addStatusCode(Resources::STATUS_NO_CONTENT);
        $httpCallContext->addStatusCode(Resources::STATUS_OK);
        $timeout = $receiveMessageOptions->getTimeout();
        if (!is_null($timeout)) {
            $httpCallContext->addQueryParameter('timeout', $timeout);
        }

        if ($receiveMessageOptions->getIsReceiveAndDelete()) {
            $httpCallContext->setMethod(Resources::HTTP_DELETE);
        } elseif ($receiveMessageOptions->getIsPeekLock()) {
            $httpCallContext->setMethod(Resources::HTTP_POST);
        } else {
            throw new \InvalidArgumentException(
                Resources::INVALID_RECEIVE_MODE_MSG
            );
        }

        $response = $this->sendHttpContext($httpCallContext);
        if ($response->getStatusCode() === Resources::STATUS_NO_CONTENT) {
            $brokeredMessage = null;
        } else {
            $responseHeaders = HttpClient::getResponseHeaders($response);

            $brokerProperties = new BrokerProperties();

            if (array_key_exists('brokerproperties', $responseHeaders)) {
                $brokerProperties = BrokerProperties::create($responseHeaders['brokerproperties']);
            }

            if (array_key_exists('location', $responseHeaders)) {
                $brokerProperties->setLockLocation($responseHeaders['location']);
            }

            $brokeredMessage = new BrokeredMessage();
            $brokeredMessage->setBrokerProperties($brokerProperties);

            if (array_key_exists(Resources::CONTENT_TYPE, $responseHeaders)) {
                $brokeredMessage->setContentType($responseHeaders[Resources::CONTENT_TYPE]);
            }

            if (array_key_exists('date', $responseHeaders)) {
                $brokeredMessage->setDate($responseHeaders['date']);
            }

            $brokeredMessage->setBody($response->getBody());

            foreach ($responseHeaders as $headerKey => $value) {
                $decodedValue = json_decode($value);
                if (is_scalar($decodedValue)) {
                    $brokeredMessage->setProperty(
                        $headerKey,
                        $decodedValue
                    );
                }
            }
        }

        return $brokeredMessage;
    }
public function receiveMessage ( $ path , ReceiveMessageOptions $ receiveMessageOptions = null ) { if ( is_null ( $ receiveMessageOptions ) ) { $ receiveMessageOptions = new ReceiveMessageOptions ( ) ; } $ httpCallContext = new HttpCallContext ( ) ; $ httpCallContext -> setPath ( $ path ) ; $ httpCallContext -> addStatusCode ( Resources :: STATUS_CREATED ) ; $ httpCallContext -> addStatusCode ( Resources :: STATUS_NO_CONTENT ) ; $ httpCallContext -> addStatusCode ( Resources :: STATUS_OK ) ; $ timeout = $ receiveMessageOptions -> getTimeout ( ) ; if ( ! is_null ( $ timeout ) ) { $ httpCallContext -> addQueryParameter ( 'timeout' , $ timeout ) ; } if ( $ receiveMessageOptions -> getIsReceiveAndDelete ( ) ) { $ httpCallContext -> setMethod ( Resources :: HTTP_DELETE ) ; } elseif ( $ receiveMessageOptions -> getIsPeekLock ( ) ) { $ httpCallContext -> setMethod ( Resources :: HTTP_POST ) ; } else { throw new \ InvalidArgumentException ( Resources :: INVALID_RECEIVE_MODE_MSG ) ; } $ response = $ this -> sendHttpContext ( $ httpCallContext ) ; if ( $ response -> getStatusCode ( ) === Resources :: STATUS_NO_CONTENT ) { $ brokeredMessage = null ; } else { $ responseHeaders = HttpClient :: getResponseHeaders ( $ response ) ; $ brokerProperties = new BrokerProperties ( ) ; if ( array_key_exists ( 'brokerproperties' , $ responseHeaders ) ) { $ brokerProperties = BrokerProperties :: create ( $ responseHeaders [ 'brokerproperties' ] ) ; } if ( array_key_exists ( 'location' , $ responseHeaders ) ) { $ brokerProperties -> setLockLocation ( $ responseHeaders [ 'location' ] ) ; } $ brokeredMessage = new BrokeredMessage ( ) ; $ brokeredMessage -> setBrokerProperties ( $ brokerProperties ) ; if ( array_key_exists ( Resources :: CONTENT_TYPE , $ responseHeaders ) ) { $ brokeredMessage -> setContentType ( $ responseHeaders [ Resources :: CONTENT_TYPE ] ) ; } if ( array_key_exists ( 'date' , $ responseHeaders ) ) { $ brokeredMessage -> setDate ( $ responseHeaders [ 'date' ] ) ; } $ brokeredMessage -> setBody ( $ response -> getBody ( ) ) ; foreach ( $ responseHeaders as $ headerKey => $ value ) { $ decodedValue = json_decode ( $ value ) ; if ( is_scalar ( $ decodedValue ) ) { $ brokeredMessage -> setProperty ( $ headerKey , $ decodedValue ) ; } } } return $ brokeredMessage ; }
Receives a message.

Queues:

@link http://msdn.microsoft.com/en-us/library/windowsazure/hh780735
@link http://msdn.microsoft.com/en-us/library/windowsazure/hh780756

Topic Subscriptions:
@link http://msdn.microsoft.com/en-us/library/windowsazure/hh780722
@link http://msdn.microsoft.com/en-us/library/windowsazure/hh780770

@param string                $path                  The path of the
message
@param ReceiveMessageOptions $receiveMessageOptions The options to
receive the message

@return BrokeredMessage
Receives a message .