本文整理匯總了Python中azure.servicebus.common.message.Message.session_id方法的典型用法代碼示例。如果您正苦於以下問題:Python Message.session_id方法的具體用法?Python Message.session_id怎麽用?Python Message.session_id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類azure.servicebus.common.message.Message
的用法示例。
在下文中一共展示了Message.session_id方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_session_message_expiry
# 需要導入模塊: from azure.servicebus.common.message import Message [as 別名]
# 或者: from azure.servicebus.common.message.Message import session_id [as 別名]
def test_session_message_expiry(live_servicebus_config, session_queue):
client = ServiceBusClient(
service_namespace=live_servicebus_config['hostname'],
shared_access_key_name=live_servicebus_config['key_name'],
shared_access_key_value=live_servicebus_config['access_key'],
debug=True)
session_id = str(uuid.uuid4())
queue_client = client.get_queue(session_queue)
with queue_client.get_sender() as sender:
message = Message("Testing expired messages")
message.session_id = session_id
sender.send(message)
with queue_client.get_receiver(session=session_id) as receiver:
messages = receiver.fetch_next(timeout=10)
assert len(messages) == 1
print_message(messages[0])
time.sleep(30)
with pytest.raises(TypeError):
messages[0].expired
with pytest.raises(TypeError):
messages[0].renew_lock()
assert receiver.expired
with pytest.raises(SessionLockExpired):
messages[0].complete()
with pytest.raises(SessionLockExpired):
receiver.renew_lock()
with queue_client.get_receiver(session=session_id) as receiver:
messages = receiver.fetch_next(timeout=30)
assert len(messages) == 1
print_message(messages[0])
#assert messages[0].header.delivery_count # TODO confirm this with service
messages[0].complete()
示例2: test_session_message_connection_closed
# 需要導入模塊: from azure.servicebus.common.message import Message [as 別名]
# 或者: from azure.servicebus.common.message.Message import session_id [as 別名]
def test_session_message_connection_closed(live_servicebus_config, session_queue):
client = ServiceBusClient(
service_namespace=live_servicebus_config['hostname'],
shared_access_key_name=live_servicebus_config['key_name'],
shared_access_key_value=live_servicebus_config['access_key'],
debug=True)
session_id = str(uuid.uuid4())
queue_client = client.get_queue(session_queue)
with queue_client.get_sender() as sender:
message = Message("test")
message.session_id = session_id
sender.send(message)
with queue_client.get_receiver(session=session_id) as receiver:
messages = receiver.fetch_next(timeout=10)
assert len(messages) == 1
with pytest.raises(MessageSettleFailed):
messages[0].complete()