This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.
MIT License
4.35k
stars
2.7k
forks
source link
Get service bus sender client by name regardless of type (queue/topic) #36192
Is your feature request related to a problem? Please describe.
I would like a way to send messages to an Azure Service Bus entity without needing to know in advance if the entity is a topic or a queue. Currently, the only way to send a message is by first creating a ServiceBusClient and using its .get_queue_sender or .get_topic_sender method to get a ServiceBusSender instance and then using its .send_messages method.
Having to know the type in advance limits the usefulness of the message ReplyTo property for a request-response pattern where some of the responses need to be delivered to a queue while others need to be delivered to a topic.
Describe the solution you'd like
Merge the .get_queue_sender and .get_topic_sender methods into a .get_sender method that takes a shared queue_or_topic_name: string parameter, instead of having separate methods or parameters queue_name: string and topic_name: string. As far as I can tell from the docs, this is exactly what the Service Bus .NET SDK does with the ServiceBusClient.CreateSender(string queueOrTopicName) method.
Describe alternatives you've considered
Two potential solutions that would work with the current SDK:
Encode the entity type in the ReplyTo property. Instead of a ReplyTo = 'response', set the value to 'queue/response' or 'topic/response'
Try to use .get_queue_sender to send the reply first. If this throws an error, retry with .get_topic_sender.
Both should work but seem like workarounds and should not be necessary given that the .NET API does not have these limitations
Is your feature request related to a problem? Please describe. I would like a way to send messages to an Azure Service Bus entity without needing to know in advance if the entity is a topic or a queue. Currently, the only way to send a message is by first creating a
ServiceBusClient
and using its.get_queue_sender
or.get_topic_sender
method to get aServiceBusSender
instance and then using its.send_messages
method.Having to know the type in advance limits the usefulness of the message
ReplyTo
property for a request-response pattern where some of the responses need to be delivered to a queue while others need to be delivered to a topic.Describe the solution you'd like Merge the
.get_queue_sender
and.get_topic_sender
methods into a.get_sender
method that takes a sharedqueue_or_topic_name: string
parameter, instead of having separate methods or parametersqueue_name: string
andtopic_name: string
. As far as I can tell from the docs, this is exactly what the Service Bus .NET SDK does with theServiceBusClient.CreateSender(string queueOrTopicName)
method.Describe alternatives you've considered Two potential solutions that would work with the current SDK:
ReplyTo
property. Instead of aReplyTo = 'response'
, set the value to'queue/response'
or'topic/response'
.get_queue_sender
to send the reply first. If this throws an error, retry with.get_topic_sender
.Both should work but seem like workarounds and should not be necessary given that the .NET API does not have these limitations