如何关闭与 Azure 服务总线队列的连接?

How to close connection with the azure service bus queue?

我可以使用他们的官方 SDK 接收消息 from azure queues。它工作正常。这是我用来从队列接收消息的片段。

   from azure.servicebus import QueueClient

   client = QueueClient.from_connection_string(
           q_string,
           q_name)

    msg = None

    with client.get_receiver() as queue_receiver:
        messages = queue_receiver.fetch_next(max_batch_size=1, timeout=3)
        if len(messages) > 0:
            msg = messages[0]
            print(f"Received {msg.message}")

    return msg

如何关闭与队列的连接?我怎样才能做到这一点? azure sdk有什么功能可用吗?

How do I close the connection with the queue? How can I do that? Is there any function available with azure sdk?

您可以在服务总线客户端上调用close方法。这将关闭服务总线客户端和底层连接。