예제 #1
0
 def delete_subscription_message(self, topic_name, subscription_name,
                                 sequence_number, lock_token):
     '''
     Completes processing on a locked message and delete it from the subscription. 
     This operation should only be called after processing a previously locked 
     message is successful to maintain At-Least-Once delivery assurances.
     
     topic_name: the name of the topic
     subscription_name: the name of the subscription
     sequence_name: The sequence number of the message to be deleted as returned 
     		in BrokerProperties['SequenceNumber'] by the Peek Message operation.
     lock_token: The ID of the lock as returned by the Peek Message operation in 
     		BrokerProperties['LockToken']
     '''
     _validate_not_none('topic_name', topic_name)
     _validate_not_none('subscription_name', subscription_name)
     _validate_not_none('sequence_number', sequence_number)
     _validate_not_none('lock_token', lock_token)
     request = HTTPRequest()
     request.method = 'DELETE'
     request.host = self._get_host()
     request.path = '/' + _str(topic_name) + '/subscriptions/' + _str(
         subscription_name) + '/messages/' + _str(
             sequence_number) + '/' + _str(lock_token) + ''
     request.path, request.query = _update_request_uri_query(request)
     request.headers = _update_service_bus_header(request, self.account_key,
                                                  self.issuer)
     response = self._perform_request(request)
예제 #2
0
    def peek_lock_queue_message(self, queue_name, timeout='60'):
        '''
        Automically retrieves and locks a message from a queue for processing. The 
        message is guaranteed not to be delivered to other receivers (on the same 
        subscription only) during the lock duration period specified in the queue 
        description. Once the lock expires, the message will be available to other 
        receivers. In order to complete processing of the message, the receiver 
        should issue a delete command with the lock ID received from this operation. 
        To abandon processing of the message and unlock it for other receivers, 
        an Unlock Message command should be issued, or the lock duration period 
        can expire.
        
        queue_name: name of the queue
        '''
        _validate_not_none('queue_name', queue_name)
        request = HTTPRequest()
        request.method = 'POST'
        request.host = self._get_host()
        request.path = '/' + _str(queue_name) + '/messages/head'
        request.query = [('timeout', _int_or_none(timeout))]
        request.path, request.query = _update_request_uri_query(request)
        request.headers = _update_service_bus_header(request, self.account_key,
                                                     self.issuer)
        response = self._perform_request(request)

        return _create_message(response, self)
예제 #3
0
    def read_delete_subscription_message(self,
                                         topic_name,
                                         subscription_name,
                                         timeout='60'):
        '''
        Read and delete a message from a subscription as an atomic operation. This 
        operation should be used when a best-effort guarantee is sufficient for an 
        application; that is, using this operation it is possible for messages to 
        be lost if processing fails.
        
        topic_name: the name of the topic
        subscription_name: the name of the subscription
        '''
        _validate_not_none('topic_name', topic_name)
        _validate_not_none('subscription_name', subscription_name)
        request = HTTPRequest()
        request.method = 'DELETE'
        request.host = self._get_host()
        request.path = '/' + _str(topic_name) + '/subscriptions/' + _str(
            subscription_name) + '/messages/head'
        request.query = [('timeout', _int_or_none(timeout))]
        request.path, request.query = _update_request_uri_query(request)
        request.headers = _update_service_bus_header(request, self.account_key,
                                                     self.issuer)
        response = self._perform_request(request)

        return _create_message(response, self)
예제 #4
0
 def create_queue(self, queue_name, queue=None, fail_on_exist=False):
     '''
     Creates a new queue. Once created, this queue's resource manifest is immutable. 
     
     queue: queue object to create. 
     queue_name: the name of the queue.
     fail_on_exist: specify whether to throw an exception when the queue exists.
     '''
     _validate_not_none('queue_name', queue_name)
     request = HTTPRequest()
     request.method = 'PUT'
     request.host = self._get_host()
     request.path = '/' + _str(queue_name) + ''
     request.body = _get_request_body(convert_queue_to_xml(queue))
     request.path, request.query = _update_request_uri_query(request)
     request.headers = _update_service_bus_header(request, self.account_key,
                                                  self.issuer)
     if not fail_on_exist:
         try:
             self._perform_request(request)
             return True
         except WindowsAzureError as e:
             _dont_fail_on_exist(e)
             return False
     else:
         self._perform_request(request)
         return True
예제 #5
0
 def delete_subscription(self,
                         topic_name,
                         subscription_name,
                         fail_not_exist=False):
     '''
     Deletes an existing subscription.
     
     topic_name: the name of the topic
     subscription_name: the name of the subscription
     fail_not_exist: specify whether to throw an exception when the subscription doesn't exist.
     '''
     _validate_not_none('topic_name', topic_name)
     _validate_not_none('subscription_name', subscription_name)
     request = HTTPRequest()
     request.method = 'DELETE'
     request.host = self._get_host()
     request.path = '/' + _str(topic_name) + '/subscriptions/' + _str(
         subscription_name) + ''
     request.path, request.query = _update_request_uri_query(request)
     request.headers = _update_service_bus_header(request, self.account_key,
                                                  self.issuer)
     if not fail_not_exist:
         try:
             self._perform_request(request)
             return True
         except WindowsAzureError as e:
             _dont_fail_not_exist(e)
             return False
     else:
         self._perform_request(request)
         return True
예제 #6
0
 def unlock_queue_message(self, queue_name, sequence_number, lock_token):
     '''
     Unlocks a message for processing by other receivers on a given subscription. 
     This operation deletes the lock object, causing the message to be unlocked. 
     A message must have first been locked by a receiver before this operation is 
     called.
     
     queue_name: name of the queue
     sequence_name: The sequence number of the message to be unlocked as returned 
     		in BrokerProperties['SequenceNumber'] by the Peek Message operation.
     lock_token: The ID of the lock as returned by the Peek Message operation in 
     		BrokerProperties['LockToken']
     '''
     _validate_not_none('queue_name', queue_name)
     _validate_not_none('sequence_number', sequence_number)
     _validate_not_none('lock_token', lock_token)
     request = HTTPRequest()
     request.method = 'PUT'
     request.host = self._get_host()
     request.path = '/' + _str(queue_name) + '/messages/' + _str(
         sequence_number) + '/' + _str(lock_token) + ''
     request.path, request.query = _update_request_uri_query(request)
     request.headers = _update_service_bus_header(request, self.account_key,
                                                  self.issuer)
     response = self._perform_request(request)
 def delete_rule(self, topic_name, subscription_name, rule_name, fail_not_exist=False):
     '''
     Deletes an existing rule.
     
     topic_name: Name of the topic.
     subscription_name: Name of the subscription.
     rule_name:
         Name of the rule to delete.  DEFAULT_RULE_NAME=$Default. 
         Use DEFAULT_RULE_NAME to delete default rule for the subscription.
     fail_not_exist:
         Specify whether throw exception when rule doesn't exist.
     '''
     _validate_not_none('topic_name', topic_name)
     _validate_not_none('subscription_name', subscription_name)
     _validate_not_none('rule_name', rule_name)
     request = HTTPRequest()
     request.method = 'DELETE'
     request.host = self._get_host()
     request.path = '/' + _str(topic_name) + '/subscriptions/' + _str(subscription_name) + '/rules/' + _str(rule_name) + ''
     request.path, request.query = _update_request_uri_query(request)
     request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
     if not fail_not_exist:
         try:
             self._perform_request(request)
             return True
         except WindowsAzureError as e:
             _dont_fail_not_exist(e)
             return False
     else:
         self._perform_request(request)
         return True
예제 #8
0
 def delete_topic(self, topic_name, fail_not_exist=False):
     '''
     Deletes an existing topic. This operation will also remove all associated state 
     including associated subscriptions.
     
     topic_name: name of the topic.
     fail_not_exist: specify whether throw exception when topic doesn't exist.
     '''
     _validate_not_none('topic_name', topic_name)
     request = HTTPRequest()
     request.method = 'DELETE'
     request.host = self._get_host()
     request.path = '/' + _str(topic_name) + ''
     request.path, request.query = _update_request_uri_query(request)
     request.headers = _update_service_bus_header(request, self.account_key,
                                                  self.issuer)
     if not fail_not_exist:
         try:
             self._perform_request(request)
             return True
         except WindowsAzureError as e:
             _dont_fail_not_exist(e)
             return False
     else:
         self._perform_request(request)
         return True
 def delete_queue_message(self, queue_name, sequence_number, lock_token):
     '''
     Completes processing on a locked message and delete it from the queue. 
     This operation should only be called after processing a previously 
     locked message is successful to maintain At-Least-Once delivery 
     assurances.
     
     queue_name: Name of the queue.
     sequence_number:
         The sequence number of the message to be deleted as returned in 
         BrokerProperties['SequenceNumber'] by the Peek Message operation.
     lock_token:
         The ID of the lock as returned by the Peek Message operation in 
         BrokerProperties['LockToken']
     '''
     _validate_not_none('queue_name', queue_name)
     _validate_not_none('sequence_number', sequence_number)
     _validate_not_none('lock_token', lock_token)
     request = HTTPRequest()
     request.method = 'DELETE'
     request.host = self._get_host()
     request.path = '/' + _str(queue_name) + '/messages/' + _str(sequence_number) + '/' + _str(lock_token) + ''
     request.path, request.query = _update_request_uri_query(request)
     request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
     response = self._perform_request(request)
 def create_topic(self, topic_name, topic=None, fail_on_exist=False):
     '''
     Creates a new topic. Once created, this topic resource manifest is 
     immutable. 
     
     topic_name: Name of the topic to create.
     topic: Topic object to create.
     fail_on_exist:
         Specify whether to throw an exception when the topic exists.
     '''
     _validate_not_none('topic_name', topic_name)
     request = HTTPRequest()
     request.method = 'PUT'
     request.host = self._get_host()
     request.path = '/' + _str(topic_name) + ''
     request.body = _get_request_body(_convert_topic_to_xml(topic))
     request.path, request.query = _update_request_uri_query(request)
     request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
     if not fail_on_exist:
         try:
             self._perform_request(request)
             return True
         except WindowsAzureError as e:
             _dont_fail_on_exist(e)
             return False
     else:
         self._perform_request(request)
         return True
예제 #11
0
 def delete_subscription(self, topic_name, subscription_name, fail_not_exist=False):
     '''
     Deletes an existing subscription.
     
     topic_name: the name of the topic
     subscription_name: the name of the subscription
     fail_not_exist: specify whether to throw an exception when the subscription doesn't exist.
     '''
     _validate_not_none('topic_name', topic_name)
     _validate_not_none('subscription_name', subscription_name)
     request = HTTPRequest()
     request.method = 'DELETE'
     request.host = self._get_host()
     request.path = '/' + str(topic_name) + '/subscriptions/' + str(subscription_name) + ''
     request.path, request.query = _update_request_uri_query(request)
     request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
     if not fail_not_exist:
         try:
             self._perform_request(request)
             return True
         except WindowsAzureError as e:
             _dont_fail_not_exist(e)
             return False
     else:
         self._perform_request(request)
         return True
 def delete_queue(self, queue_name, fail_not_exist=False):
     '''
     Deletes an existing queue. This operation will also remove all 
     associated state including messages in the queue.
     
     queue_name: Name of the queue to delete.
     fail_not_exist:
         Specify whether to throw an exception if the queue doesn't exist.
     '''
     _validate_not_none('queue_name', queue_name)
     request = HTTPRequest()
     request.method = 'DELETE'
     request.host = self._get_host()
     request.path = '/' + _str(queue_name) + ''
     request.path, request.query = _update_request_uri_query(request)
     request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
     if not fail_not_exist:
         try:
             self._perform_request(request)
             return True
         except WindowsAzureError as e:
             _dont_fail_not_exist(e)
             return False
     else:
         self._perform_request(request)
         return True
예제 #13
0
 def delete_topic(self, topic_name, fail_not_exist=False):
     '''
     Deletes an existing topic. This operation will also remove all associated state 
     including associated subscriptions.
     
     topic_name: name of the topic.
     fail_not_exist: specify whether throw exception when topic doesn't exist.
     '''
     _validate_not_none('topic_name', topic_name)
     request = HTTPRequest()
     request.method = 'DELETE'
     request.host = self._get_host()
     request.path = '/' + str(topic_name) + ''
     request.path, request.query = _update_request_uri_query(request)
     request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
     if not fail_not_exist:
         try:
             self._perform_request(request)
             return True
         except WindowsAzureError as e:
             _dont_fail_not_exist(e)
             return False
     else:
         self._perform_request(request)
         return True
예제 #14
0
 def create_subscription(self, topic_name, subscription_name, subscription=None, fail_on_exist=False):
     '''
     Creates a new subscription. Once created, this subscription resource manifest is 
     immutable. 
     
     topic_name: the name of the topic
     subscription_name: the name of the subscription
     fail_on_exist: specify whether throw exception when subscription exists.
     '''
     _validate_not_none('topic_name', topic_name)
     _validate_not_none('subscription_name', subscription_name)
     request = HTTPRequest()
     request.method = 'PUT'
     request.host = self._get_host()
     request.path = '/' + str(topic_name) + '/subscriptions/' + str(subscription_name) + ''
     request.body = _get_request_body(convert_subscription_to_xml(subscription))
     request.path, request.query = _update_request_uri_query(request)
     request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
     if not fail_on_exist:
         try:
             self._perform_request(request)
             return True
         except WindowsAzureError as e:
             _dont_fail_on_exist(e)
             return False
     else:
         self._perform_request(request)
         return True
예제 #15
0
 def create_queue(self, queue_name, queue=None, fail_on_exist=False):
     '''
     Creates a new queue. Once created, this queue's resource manifest is immutable. 
     
     queue: queue object to create. 
     queue_name: the name of the queue.
     fail_on_exist: specify whether to throw an exception when the queue exists.
     '''
     _validate_not_none('queue_name', queue_name)
     request = HTTPRequest()
     request.method = 'PUT'
     request.host = self._get_host()
     request.path = '/' + str(queue_name) + ''
     request.body = _get_request_body(convert_queue_to_xml(queue))
     request.path, request.query = _update_request_uri_query(request)
     request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
     if not fail_on_exist:
         try:
             self._perform_request(request)
             return True
         except WindowsAzureError as e:
             _dont_fail_on_exist(e)
             return False
     else:
         self._perform_request(request)
         return True
예제 #16
0
 def unlock_subscription_message(self, topic_name, subscription_name, sequence_number, lock_token):
     '''
     Unlock a message for processing by other receivers on a given subscription. 
     This operation deletes the lock object, causing the message to be unlocked. 
     A message must have first been locked by a receiver before this operation 
     is called.
     
     topic_name: the name of the topic
     subscription_name: the name of the subscription
     sequence_name: The sequence number of the message to be unlocked as returned 
     		in BrokerProperties['SequenceNumber'] by the Peek Message operation.
     lock_token: The ID of the lock as returned by the Peek Message operation in 
     		BrokerProperties['LockToken']
     '''
     _validate_not_none('topic_name', topic_name)
     _validate_not_none('subscription_name', subscription_name)
     _validate_not_none('sequence_number', sequence_number)
     _validate_not_none('lock_token', lock_token)
     request = HTTPRequest()
     request.method = 'PUT'
     request.host = self._get_host()
     request.path = '/' + str(topic_name) + '/subscriptions/' + str(subscription_name) + '/messages/' + str(sequence_number) + '/' + str(lock_token) + ''
     request.path, request.query = _update_request_uri_query(request)
     request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
     response = self._perform_request(request)
예제 #17
0
    def peek_lock_queue_message(self, queue_name, timeout='60'):
        '''
        Automically retrieves and locks a message from a queue for processing. The 
        message is guaranteed not to be delivered to other receivers (on the same 
        subscription only) during the lock duration period specified in the queue 
        description. Once the lock expires, the message will be available to other 
        receivers. In order to complete processing of the message, the receiver 
        should issue a delete command with the lock ID received from this operation. 
        To abandon processing of the message and unlock it for other receivers, 
        an Unlock Message command should be issued, or the lock duration period 
        can expire.
        
        queue_name: name of the queue
        '''
        _validate_not_none('queue_name', queue_name)
        request = HTTPRequest()
        request.method = 'POST'
        request.host = self._get_host()
        request.path = '/' + str(queue_name) + '/messages/head'
        request.query = [('timeout', _int_or_none(timeout))]
        request.path, request.query = _update_request_uri_query(request)
        request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
        response = self._perform_request(request)

        return _create_message(response, self)
예제 #18
0
 def create_subscription(self,
                         topic_name,
                         subscription_name,
                         subscription=None,
                         fail_on_exist=False):
     '''
     Creates a new subscription. Once created, this subscription resource manifest is 
     immutable. 
     
     topic_name: the name of the topic
     subscription_name: the name of the subscription
     fail_on_exist: specify whether throw exception when subscription exists.
     '''
     _validate_not_none('topic_name', topic_name)
     _validate_not_none('subscription_name', subscription_name)
     request = HTTPRequest()
     request.method = 'PUT'
     request.host = self._get_host()
     request.path = '/' + _str(topic_name) + '/subscriptions/' + _str(
         subscription_name) + ''
     request.body = _get_request_body(
         convert_subscription_to_xml(subscription))
     request.path, request.query = _update_request_uri_query(request)
     request.headers = _update_service_bus_header(request, self.account_key,
                                                  self.issuer)
     if not fail_on_exist:
         try:
             self._perform_request(request)
             return True
         except WindowsAzureError as e:
             _dont_fail_on_exist(e)
             return False
     else:
         self._perform_request(request)
         return True
    def list_topics(self):
        '''
        Retrieves the topics in the service namespace.
        '''
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self.service_namespace + SERVICE_BUS_HOST_BASE
        request.path = '/$Resources/Topics'
        request.path, request.query = _update_request_uri_query(request)
        request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
        response = self._perform_request(request)

        return _convert_response_to_feeds(response, _convert_xml_to_topic)
예제 #20
0
    def list_topics(self):
        '''
        Retrieves the topics in the service namespace.
        '''
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self._get_host()
        request.path = '/$Resources/Topics'
        request.path, request.query = _update_request_uri_query(request)
        request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
        response = self._perform_request(request)

        return _convert_response_to_feeds(response, _convert_xml_to_topic)
    def list_queues(self):
        '''
        Enumerates the queues in the service namespace.
        '''
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self.service_namespace + SERVICE_BUS_HOST_BASE
        request.path = '/$Resources/Queues'
        request.path, request.query = _update_request_uri_query(request)
        request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
        response = self._perform_request(request)

        return _convert_response_to_feeds(response, _convert_xml_to_queue)
    def list_queues(self):
        '''
        Enumerates the queues in the service namespace.
        '''
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self._get_host()
        request.path = '/$Resources/Queues'
        request.path, request.query = _update_request_uri_query(request)
        request.headers = _update_service_bus_header(request, self.account_key,
                                                     self.issuer)
        response = self._perform_request(request)

        return _convert_response_to_feeds(response, _convert_xml_to_queue)
예제 #23
0
    def get_topic(self, topic_name):
        '''
        Retrieves the description for the specified topic.
        
        topic_name: name of the topic.
        '''
        _validate_not_none('topic_name', topic_name)
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self._get_host()
        request.path = '/' + str(topic_name) + ''
        request.path, request.query = _update_request_uri_query(request)
        request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
        response = self._perform_request(request)

        return _convert_response_to_topic(response)
예제 #24
0
    def list_subscriptions(self, topic_name):
        '''
        Retrieves the subscriptions in the specified topic. 
        
        topic_name: the name of the topic
        '''
        _validate_not_none('topic_name', topic_name)
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self._get_host()
        request.path = '/' + str(topic_name) + '/subscriptions/'
        request.path, request.query = _update_request_uri_query(request)
        request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
        response = self._perform_request(request)

        return _convert_response_to_feeds(response, _convert_xml_to_subscription)
    def get_queue(self, queue_name):
        '''
        Retrieves an existing queue.
        
        queue_name: name of the queue.
        '''
        _validate_not_none('queue_name', queue_name)
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self.service_namespace + SERVICE_BUS_HOST_BASE
        request.path = '/' + str(queue_name) + ''
        request.path, request.query = _update_request_uri_query(request)
        request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
        response = self._perform_request(request)

        return _convert_response_to_queue(response)
    def list_subscriptions(self, topic_name):
        '''
        Retrieves the subscriptions in the specified topic. 
        
        topic_name: the name of the topic
        '''
        _validate_not_none('topic_name', topic_name)
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self.service_namespace + SERVICE_BUS_HOST_BASE
        request.path = '/' + str(topic_name) + '/subscriptions/'
        request.path, request.query = _update_request_uri_query(request)
        request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
        response = self._perform_request(request)

        return _convert_response_to_feeds(response, _convert_xml_to_subscription)
예제 #27
0
    def get_queue(self, queue_name):
        '''
        Retrieves an existing queue.
        
        queue_name: name of the queue.
        '''
        _validate_not_none('queue_name', queue_name)
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self._get_host()
        request.path = '/' + str(queue_name) + ''
        request.path, request.query = _update_request_uri_query(request)
        request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
        response = self._perform_request(request)

        return _convert_response_to_queue(response)
    def get_topic(self, topic_name):
        '''
        Retrieves the description for the specified topic.
        
        topic_name: Name of the topic.
        '''
        _validate_not_none('topic_name', topic_name)
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self._get_host()
        request.path = '/' + _str(topic_name) + ''
        request.path, request.query = _update_request_uri_query(request)
        request.headers = _update_service_bus_header(request, self.account_key,
                                                     self.issuer)
        response = self._perform_request(request)

        return _convert_response_to_topic(response)
예제 #29
0
    def get_subscription(self, topic_name, subscription_name):
        '''
        Gets an existing subscription.
        
        topic_name: the name of the topic
        subscription_name: the name of the subscription
        '''
        _validate_not_none('topic_name', topic_name)
        _validate_not_none('subscription_name', subscription_name)
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self._get_host()
        request.path = '/' + str(topic_name) + '/subscriptions/' + str(subscription_name) + ''
        request.path, request.query = _update_request_uri_query(request)
        request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
        response = self._perform_request(request)

        return _convert_response_to_subscription(response)
    def get_subscription(self, topic_name, subscription_name):
        '''
        Gets an existing subscription.
        
        topic_name: the name of the topic
        subscription_name: the name of the subscription
        '''
        _validate_not_none('topic_name', topic_name)
        _validate_not_none('subscription_name', subscription_name)
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self.service_namespace + SERVICE_BUS_HOST_BASE
        request.path = '/' + str(topic_name) + '/subscriptions/' + str(subscription_name) + ''
        request.path, request.query = _update_request_uri_query(request)
        request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
        response = self._perform_request(request)

        return _convert_response_to_subscription(response)
    def list_rules(self, topic_name, subscription_name):
        '''
        Retrieves the rules that exist under the specified subscription. 
        
        topic_name: the name of the topic
        subscription_name: the name of the subscription
        '''
        _validate_not_none('topic_name', topic_name)
        _validate_not_none('subscription_name', subscription_name)
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self.service_namespace + SERVICE_BUS_HOST_BASE
        request.path = '/' + str(topic_name) + '/subscriptions/' + str(subscription_name) + '/rules/'
        request.path, request.query = _update_request_uri_query(request)
        request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
        response = self._perform_request(request)

        return _convert_response_to_feeds(response, _convert_xml_to_rule)
    def read_delete_queue_message(self, queue_name, timeout='60'):
        '''
        Reads and deletes a message from a queue as an atomic operation. This operation 
        should be used when a best-effort guarantee is sufficient for an application; 
        that is, using this operation it is possible for messages to be lost if 
        processing fails.
        
        queue_name: name of the queue
        '''
        _validate_not_none('queue_name', queue_name)
        request = HTTPRequest()
        request.method = 'DELETE'
        request.host = self.service_namespace + SERVICE_BUS_HOST_BASE
        request.path = '/' + str(queue_name) + '/messages/head'
        request.query = [('timeout', _int_or_none(timeout))]
        request.path, request.query = _update_request_uri_query(request)
        request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
        response = self._perform_request(request)

        return _create_message(response, self)
    def list_rules(self, topic_name, subscription_name):
        '''
        Retrieves the rules that exist under the specified subscription. 
        
        topic_name: Name of the topic.
        subscription_name: Name of the subscription.
        '''
        _validate_not_none('topic_name', topic_name)
        _validate_not_none('subscription_name', subscription_name)
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self._get_host()
        request.path = '/' + _str(topic_name) + '/subscriptions/' + _str(
            subscription_name) + '/rules/'
        request.path, request.query = _update_request_uri_query(request)
        request.headers = _update_service_bus_header(request, self.account_key,
                                                     self.issuer)
        response = self._perform_request(request)

        return _convert_response_to_feeds(response, _convert_xml_to_rule)
 def send_queue_message(self, queue_name, message=None):
     '''
     Sends a message into the specified queue. The limit to the number of messages 
     which may be present in the topic is governed by the message size the 
     MaxTopicSizeInMegaBytes. If this message will cause the queue to exceed its 
     quota, a quota exceeded error is returned and the message will be rejected.
     
     queue_name: name of the queue
     message: the Message object containing message body and properties.
     '''
     _validate_not_none('queue_name', queue_name)
     request = HTTPRequest()
     request.method = 'POST'
     request.host = self.service_namespace + SERVICE_BUS_HOST_BASE
     request.path = '/' + str(queue_name) + '/messages'
     request.headers = message.add_headers(request)
     request.body = _get_request_body(message.body)
     request.path, request.query = _update_request_uri_query(request)
     request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
     response = self._perform_request(request)
예제 #35
0
    def read_delete_queue_message(self, queue_name, timeout='60'):
        '''
        Reads and deletes a message from a queue as an atomic operation. This operation 
        should be used when a best-effort guarantee is sufficient for an application; 
        that is, using this operation it is possible for messages to be lost if 
        processing fails.
        
        queue_name: name of the queue
        '''
        _validate_not_none('queue_name', queue_name)
        request = HTTPRequest()
        request.method = 'DELETE'
        request.host = self._get_host()
        request.path = '/' + str(queue_name) + '/messages/head'
        request.query = [('timeout', _int_or_none(timeout))]
        request.path, request.query = _update_request_uri_query(request)
        request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
        response = self._perform_request(request)

        return _create_message(response, self)
    def get_rule(self, topic_name, subscription_name, rule_name):
        '''
        Retrieves the description for the specified rule. 
        
        topic_name: Name of the topic.
        subscription_name: Name of the subscription.
        rule_name: Name of the rule.
        '''
        _validate_not_none('topic_name', topic_name)
        _validate_not_none('subscription_name', subscription_name)
        _validate_not_none('rule_name', rule_name)
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self._get_host()
        request.path = '/' + _str(topic_name) + '/subscriptions/' + _str(subscription_name) + '/rules/' + _str(rule_name) + ''
        request.path, request.query = _update_request_uri_query(request)
        request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
        response = self._perform_request(request)

        return _convert_response_to_rule(response)
예제 #37
0
 def send_queue_message(self, queue_name, message=None):
     '''
     Sends a message into the specified queue. The limit to the number of messages 
     which may be present in the topic is governed by the message size the 
     MaxTopicSizeInMegaBytes. If this message will cause the queue to exceed its 
     quota, a quota exceeded error is returned and the message will be rejected.
     
     queue_name: name of the queue
     message: the Message object containing message body and properties.
     '''
     _validate_not_none('queue_name', queue_name)
     request = HTTPRequest()
     request.method = 'POST'
     request.host = self._get_host()
     request.path = '/' + str(queue_name) + '/messages'
     request.headers = message.add_headers(request)
     request.body = _get_request_body(message.body)
     request.path, request.query = _update_request_uri_query(request)
     request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
     response = self._perform_request(request)
    def get_rule(self, topic_name, subscription_name, rule_name):
        '''
        Retrieves the description for the specified rule. 
        
        topic_name: the name of the topic
        subscription_name: the name of the subscription
        rule_name: name of the rule
        '''
        _validate_not_none('topic_name', topic_name)
        _validate_not_none('subscription_name', subscription_name)
        _validate_not_none('rule_name', rule_name)
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self.service_namespace + SERVICE_BUS_HOST_BASE
        request.path = '/' + str(topic_name) + '/subscriptions/' + str(subscription_name) + '/rules/' + str(rule_name) + ''
        request.path, request.query = _update_request_uri_query(request)
        request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
        response = self._perform_request(request)

        return _convert_response_to_rule(response)
 def send_topic_message(self, topic_name, message=None):
     '''
     Enqueues a message into the specified topic. The limit to the number 
     of messages which may be present in the topic is governed by the 
     message size in MaxTopicSizeInBytes. If this message causes the topic 
     to exceed its quota, a quota exceeded error is returned and the 
     message will be rejected.
     
     topic_name: Name of the topic.
     message: Message object containing message body and properties.
     '''
     _validate_not_none('topic_name', topic_name)
     request = HTTPRequest()
     request.method = 'POST'
     request.host = self._get_host()
     request.path = '/' + _str(topic_name) + '/messages'
     request.headers = message.add_headers(request)
     request.body = _get_request_body(message.body)
     request.path, request.query = _update_request_uri_query(request)
     request.headers = _update_service_bus_header(request, self.account_key,
                                                  self.issuer)
     response = self._perform_request(request)
    def read_delete_subscription_message(self, topic_name, subscription_name, timeout='60'):
        '''
        Read and delete a message from a subscription as an atomic operation. This 
        operation should be used when a best-effort guarantee is sufficient for an 
        application; that is, using this operation it is possible for messages to 
        be lost if processing fails.
        
        topic_name: the name of the topic
        subscription_name: the name of the subscription
        '''
        _validate_not_none('topic_name', topic_name)
        _validate_not_none('subscription_name', subscription_name)
        request = HTTPRequest()
        request.method = 'DELETE'
        request.host = self.service_namespace + SERVICE_BUS_HOST_BASE
        request.path = '/' + str(topic_name) + '/subscriptions/' + str(subscription_name) + '/messages/head'
        request.query = [('timeout', _int_or_none(timeout))]
        request.path, request.query = _update_request_uri_query(request)
        request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
        response = self._perform_request(request)

        return _create_message(response, self)
 def delete_rule(self,
                 topic_name,
                 subscription_name,
                 rule_name,
                 fail_not_exist=False):
     '''
     Deletes an existing rule.
     
     topic_name: Name of the topic.
     subscription_name: Name of the subscription.
     rule_name:
         Name of the rule to delete.  DEFAULT_RULE_NAME=$Default. 
         Use DEFAULT_RULE_NAME to delete default rule for the subscription.
     fail_not_exist:
         Specify whether throw exception when rule doesn't exist.
     '''
     _validate_not_none('topic_name', topic_name)
     _validate_not_none('subscription_name', subscription_name)
     _validate_not_none('rule_name', rule_name)
     request = HTTPRequest()
     request.method = 'DELETE'
     request.host = self._get_host()
     request.path = '/' + _str(topic_name) + '/subscriptions/' + _str(
         subscription_name) + '/rules/' + _str(rule_name) + ''
     request.path, request.query = _update_request_uri_query(request)
     request.headers = _update_service_bus_header(request, self.account_key,
                                                  self.issuer)
     if not fail_not_exist:
         try:
             self._perform_request(request)
             return True
         except WindowsAzureError as e:
             _dont_fail_not_exist(e)
             return False
     else:
         self._perform_request(request)
         return True
 def delete_queue(self, queue_name, fail_not_exist=False):
     '''
     Deletes an existing queue. This operation will also remove all associated state 
     including messages in the queue.
     
     fail_not_exist: specify whether to throw an exception if the queue doesn't exist.
     '''
     _validate_not_none('queue_name', queue_name)
     request = HTTPRequest()
     request.method = 'DELETE'
     request.host = self.service_namespace + SERVICE_BUS_HOST_BASE
     request.path = '/' + str(queue_name) + ''
     request.path, request.query = _update_request_uri_query(request)
     request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
     if not fail_not_exist:
         try:
             self._perform_request(request)
             return True
         except WindowsAzureError as e:
             _dont_fail_not_exist(e)
             return False
     else:
         self._perform_request(request)
         return True
 def renewlock_queue_message(self, queue_name, message_id, lock_token):
     '''
     Renews an already locked message for continuing processing (long running 
     operations). A message must have first been locked by a receiver before 
     this operation is called.
     
     queue_name: Name of the queue.
     message_id:
         The ID of the message whose lock is to be renewed as returned in 
         BrokerProperties['MessageId'] by the Peek Message operation.
     lock_token:
         The ID of the lock as returned by the Peek Message operation in 
         BrokerProperties['LockToken']
     '''
     _validate_not_none('queue_name', queue_name)
     _validate_not_none('message_id', message_id)
     _validate_not_none('lock_token', lock_token)
     request = HTTPRequest()
     request.method = 'POST'
     request.host = self._get_host()
     request.path = '/' + _str(queue_name) + '/messages/' + _str(message_id) + '/' + _str(lock_token) + ''
     request.path, request.query = _update_request_uri_query(request)
     request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
     response = self._perform_request(request)