当前位置: 首页>>代码示例>>Python>>正文


Python ServiceBusService.get_queue方法代码示例

本文整理汇总了Python中azure.servicebus.ServiceBusService.get_queue方法的典型用法代码示例。如果您正苦于以下问题:Python ServiceBusService.get_queue方法的具体用法?Python ServiceBusService.get_queue怎么用?Python ServiceBusService.get_queue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在azure.servicebus.ServiceBusService的用法示例。


在下文中一共展示了ServiceBusService.get_queue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: updateSlack

# 需要导入模块: from azure.servicebus import ServiceBusService [as 别名]
# 或者: from azure.servicebus.ServiceBusService import get_queue [as 别名]
def updateSlack():
    hostname = socket.gethostname()
    logMessage = "SLACKER (" + hostname + "): Checking queue size and posting to Slack starting @ " + str(time.ctime())
    log = Log()
    log.info(logMessage)
    notify.info(logMessage)  
    
    # Gather environment variables
    AZURE_SB_SERVICE_NAMESPACE = os.getenv('AZURE_SB_SERVICE_NAMESPACE')
    AZURE_SB_SHARED_ACCESS_KEY_NAME = os.getenv('AZURE_SB_SHARED_ACCESS_KEY_NAME')
    AZURE_SB_SHARED_ACCESS_KEY = os.getenv('AZURE_SB_SHARED_ACCESS_KEY')
    
    # Connect to Azure Service Bus
    sb_service = ServiceBusService(service_namespace=AZURE_SB_SERVICE_NAMESPACE,shared_access_key_name=AZURE_SB_SHARED_ACCESS_KEY_NAME,shared_access_key_value=AZURE_SB_SHARED_ACCESS_KEY)
        
    while True:
        # Delay for 6 seconds
        time.sleep(6)
        sbqueue = sb_service.get_queue('statistics')
        queuelength = sbqueue.message_count 
        logMessage = "SLACKER: Queue length is approximately: " + str(queuelength)
        log.info(logMessage)
        notify.info(logMessage)  
开发者ID:chzbrgr71,项目名称:acs-simulator-demo,代码行数:25,代码来源:slacker.py

示例2: ServiceBusTest

# 需要导入模块: from azure.servicebus import ServiceBusService [as 别名]
# 或者: from azure.servicebus.ServiceBusService import get_queue [as 别名]

#.........这里部分代码省略.........

        # Assert
        self.assertTrue(created)

    def test_create_queue_no_options_fail_on_exist(self):
        # Arrange

        # Act
        created = self.sbs.create_queue(self.queue_name, None, True)

        # Assert
        self.assertTrue(created)

    def test_create_queue_with_options(self):
        # Arrange

        # Act
        queue_options = Queue()
        queue_options.default_message_time_to_live = 'PT1M'
        queue_options.duplicate_detection_history_time_window = 'PT5M'
        queue_options.enable_batched_operations = False
        queue_options.dead_lettering_on_message_expiration = False
        queue_options.lock_duration = 'PT1M'
        queue_options.max_delivery_count = 15
        queue_options.max_size_in_megabytes = 5120
        queue_options.message_count = 0
        queue_options.requires_duplicate_detection = False
        queue_options.requires_session = False
        queue_options.size_in_bytes = 0
        created = self.sbs.create_queue(self.queue_name, queue_options)

        # Assert
        self.assertTrue(created)
        queue = self.sbs.get_queue(self.queue_name)
        self.assertEquals('PT1M', queue.default_message_time_to_live)
        self.assertEquals(
            'PT5M', queue.duplicate_detection_history_time_window)
        self.assertEquals(False, queue.enable_batched_operations)
        self.assertEquals(False, queue.dead_lettering_on_message_expiration)
        self.assertEquals('PT1M', queue.lock_duration)
        self.assertEquals(15, queue.max_delivery_count)
        self.assertEquals(5120, queue.max_size_in_megabytes)
        self.assertEquals(0, queue.message_count)
        self.assertEquals(False, queue.requires_duplicate_detection)
        self.assertEquals(False, queue.requires_session)
        self.assertEquals(0, queue.size_in_bytes)

    def test_create_queue_with_already_existing_queue(self):
        # Arrange

        # Act
        created1 = self.sbs.create_queue(self.queue_name)
        created2 = self.sbs.create_queue(self.queue_name)

        # Assert
        self.assertTrue(created1)
        self.assertFalse(created2)

    def test_create_queue_with_already_existing_queue_fail_on_exist(self):
        # Arrange

        # Act
        created = self.sbs.create_queue(self.queue_name)
        with self.assertRaises(WindowsAzureError):
            self.sbs.create_queue(self.queue_name, None, True)
开发者ID:slick666,项目名称:azure-sdk-for-python,代码行数:69,代码来源:test_servicebusservice.py


注:本文中的azure.servicebus.ServiceBusService.get_queue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。