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


Python Message.dead_letter方法代码示例

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


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

示例1: test_pqueue_by_servicebus_client_receive_batch_with_deadletter

# 需要导入模块: from azure.servicebus.common.message import Message [as 别名]
# 或者: from azure.servicebus.common.message.Message import dead_letter [as 别名]
def test_pqueue_by_servicebus_client_receive_batch_with_deadletter(live_servicebus_config, partitioned_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)

    queue_client = client.get_queue(partitioned_queue)
    with queue_client.get_receiver(idle_timeout=5, mode=ReceiveSettleMode.PeekLock, prefetch=10) as receiver:

        with queue_client.get_sender() as sender:
            for i in range(10):
                message = Message("Dead lettered message no. {}".format(i))
                sender.send(message)

        count = 0
        messages = receiver.fetch_next()
        while messages:
            for message in messages:
                print_message(message)
                count += 1
                message.dead_letter(description="Testing")
            messages = receiver.fetch_next()

    assert count == 10

    with queue_client.get_receiver(idle_timeout=5, mode=ReceiveSettleMode.PeekLock) as receiver:
        count = 0
        for message in receiver:
            print_message(message)
            message.complete()
            count += 1
    assert count == 0
开发者ID:Azure,项目名称:azure-sdk-for-python,代码行数:36,代码来源:test_partitioned_queues.py

示例2: test_session_by_servicebus_client_fetch_next_with_retrieve_deadletter

# 需要导入模块: from azure.servicebus.common.message import Message [as 别名]
# 或者: from azure.servicebus.common.message.Message import dead_letter [as 别名]
def test_session_by_servicebus_client_fetch_next_with_retrieve_deadletter(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)

    queue_client = client.get_queue(session_queue)
    session_id = str(uuid.uuid4())
    with queue_client.get_receiver(session=session_id, idle_timeout=5, prefetch=10) as receiver:

        with queue_client.get_sender(session=session_id) as sender:
            for i in range(10):
                message = Message("Dead lettered message no. {}".format(i))
                sender.send(message)

        count = 0
        messages = receiver.fetch_next()
        while messages:
            for message in messages:
                print_message(message)
                message.dead_letter(description="Testing queue deadletter")
                count += 1
            messages = receiver.fetch_next()
    assert count == 10

    with queue_client.get_deadletter_receiver(idle_timeout=5) as session:
        count = 0
        for message in session:
            print_message(message)
            message.complete()
            #assert message.user_properties[b'DeadLetterReason'] == b'something'  # TODO
            #assert message.user_properties[b'DeadLetterErrorDescription'] == b'something'  # TODO
            count += 1
    assert count == 10
开发者ID:Azure,项目名称:azure-sdk-for-python,代码行数:38,代码来源:test_sessions.py


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