本文整理汇总了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)
示例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)