azure-sdk-for-python icon indicating copy to clipboard operation
azure-sdk-for-python copied to clipboard

[Service Bus] Configurable wait time for opening SessionReceiver using NEXT_AVAILABLE

Open yunhaoling opened this issue 5 years ago • 4 comments

When SessionReceiver is created with session_id being NEXT_AVAILABLE and if there's no available session on the service side, after 60s (service side setting), a timeout exception would be returned from the service indicating no session available.

It would be nice to give customers the granular control of how long to wait for session receiver opening attempt before giving up.

Proposal for the API: https://gist.github.com/JoshLove-msft/85591feab32adecf7f53df57d0238d26 ServiceBusClient.get_queue_session_receiver(queue_name, idle_timeout, max_create_wait_time=60)

Customer reported issue: https://github.com/Azure/azure-sdk-for-python/issues/9402

yunhaoling avatar May 18 '20 21:05 yunhaoling

Hello @yunhaoling, I am the original poster of this issue and I want to tell you I am currently trying to migrate to the v7 of the SDK and I am still very much following this issue waiting for a positive outcome :)

Also, and pardon me if this is not the right place but the docs for v7 are a little sparse and all over the place, right now I am actually trying to do the opposite of my usual operations : getting a smaller timeout.

What happens is that I want to check if a subscription exists, which was very easy with the legacy control_client. With the new version the only way I found is to use get_subscription_receiver, but since all my subscriptions are session-enabled, I need to use NEXT_AVAILABLE_SESSION and get the answer only after the 1mn timeout.

Is there a better way to check for the need to create a session-enabled subscription ? If not, this issue is also blocking in that matter

K3UL avatar Dec 08 '20 11:12 K3UL

hey @K3UL, the timeout support is still undergoing discussion in the team. sorry I can't guarantee a time for you.

but for the legacy control_client, we still keep that functionality but it's in a different module now -- azure.servicebus.management. (There is an async version azure.servicebus.aio.management as well.)

You could use azure.servicebus.management.ServiceBusAdministrationClient to check if a subscription exists. sample code is here: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/servicebus/azure-servicebus/samples/sync_samples/mgmt_subscription.py.

azure.servicebus.management.ServiceBusAdministrationClient.list_subscriptions will return all the subscriptions under the topic, and it would return a list SubscriptionProperties which contains the subscription information -- SubscriptionProperties.requires_session could be used to check whether it's a sessionful entity or not.

yunhaoling avatar Dec 08 '20 19:12 yunhaoling

Oh wow I spent all day looking for something like this or the old ServiceBusClient.mgmt_client. That is very helpful, thank you very much !

K3UL avatar Dec 08 '20 19:12 K3UL

@K3UL , apologize for the inconvenience! (we intend not to promote that module :P)

yunhaoling avatar Dec 08 '20 20:12 yunhaoling