airtai / faststream

FastStream is a powerful and easy-to-use Python framework for building asynchronous services interacting with event streams such as Apache Kafka, RabbitMQ, NATS and Redis.
https://faststream.airt.ai/latest/
Apache License 2.0
2.11k stars 99 forks source link

Azure Servicebus Topics support #822

Open macieyng opened 8 months ago

macieyng commented 8 months ago

To suggest an idea or inquire about a new Message Broker supporting feature or any other enhancement, please follow this template:

Is your feature request related to a problem? Please describe. Provide a clear and concise description of the problem you've encountered. For example: "I'm always frustrated when..."

Backend I'm working on is deployed to Azure. We use FastAPI extensively and often our endpoints are dispatching messages to various Azure Service Bus queues and topics. We would like to adapt FastStream in our backend, because it has nice and simple API and docs generation, but Azure SB is the only thing we use and without broker/connector for that we're stuck with Azure SDK and our own layers for more simpler API.

Describe the solution you'd like Add Azure Service Bus broker as a subscriber and publisher.

Feature code example To help others understand the proposed feature, illustrate it with a FastStream code example:

from faststream import FastStream
from faststream.azure import AzureServiceBusBroker

broker = AzureServiceBusBroker("sb://path.to.azure")

@broker.subscriber("in")
@broker.publisher("out")
async def handle_msg(data: User) -> str:
    return f"User: {data.user} - {data.user_id} registered"

...

Describe alternatives you've considered Use SB SDK and hope that actual events are in sync with written documentation.

Additional context I know that Azure Service Bus SDK was using uamqp lib under the hood and now they changed that their own implementation of pyamqp (turns out there are at least 3 implementations under this name). This could imply that sb protocol is somewhat similar to amqp, but I'm not sure.

This is kind of interesting project and topic to me and would love to learn more about it from you guys.

In the future this may extend to Event Grid or Event Hub - those I'm not familiar with.

Lancetnik commented 8 months ago

Thanks for you feature request! Unfortunatelly, Redis and SQS is a prior tasks for now, cuz they are widely used, but sure, we'll add the Azure SB support in a few months (I hope so). You can help us by share links on Azure SB and SDK you are using to help deep into details.

ColinBe95 commented 2 months ago

@macieyng

In the future this may extend to Event Grid or Event Hub

Implementation with Azure Event Hub is already possible by using the Kafkabroker with Eventhub :-)

However, I would also love to see an Azure Service Bus implementation. I am using the Kafkabroker on Eventhub for now, but it does not fit all our use cases perfectly. I can see that SQS is a prio, but just wanted to leave my support for this feature request here, thank you very much!

black-snow commented 1 month ago

Grid + Bus would sure be nice.