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.35k stars 118 forks source link

MQTT support #956

Open Timtam94 opened 9 months ago

Timtam94 commented 9 months ago

Hi there,

in a lot of my projects in the IoT space I tend to work with RabbitMQ and Kafka but also MQTT. I would really appreciate a framework such as yours, that combine these protocols into one.

Thank you very much for your work!

Lancetnik commented 9 months ago

Thank you for your kind words! We'll support for MQTT for sure in the future, but we should finish with the brokers already in backlog at first 😞

davorrunje commented 9 months ago

@Timtam94 what lib are you currently using for MQTT?

Timtam94 commented 9 months ago

Thanks for your reply! I am currently using paho-mqtt

davorrunje commented 9 months ago

How stable it is? It looks not well maintained

Lancetnik commented 9 months ago

As I know, this is the only one lib for MQTT in python Probably, it has no commits last time cuz MQTT has no changes for decades

Timtam94 commented 9 months ago

Indeed, I am not aware of another library than that. So far I had no issues with it.

In the industrial sector, MQTT is one of the major protocols, despite it's age.

gegnew commented 9 months ago

There's also an async wrapper for paho: https://github.com/sbtinstruments/aiomqtt

Lancetnik commented 9 months ago

There's also an async wrapper for paho: https://github.com/sbtinstruments/aiomqtt

Yep, I known about it But I am not sure about using extra dependencie... Probably, we should (and can) wrap paho by ourselves the same way

skewty commented 2 months ago

There's also an async wrapper for paho: https://github.com/sbtinstruments/aiomqtt

Yep, I known about it But I am not sure about using extra dependencie... Probably, we should (and can) wrap paho by ourselves the same way

aiomqtt's dependencies are minimal. Here they are from pyproject.toml

[tool.poetry.dependencies]
python = "^3.8"
paho-mqtt = "^2.1.0"
typing-extensions = {version = "^4.4.0", markers = "python_version < '3.10'"}

Paho recently had a v2 release which aiomqtt is using. Paho uses a legacy callback system and is rather ugly (very non pythonic) to work with. The aiomqtt team is careful not to couple too deep into paho client as to ensure aiomqtt remains easy to maintain. The wrapper is light but non trivial. aiomqtt is likely worth coupling for this reason.

benedikt-bartscher commented 1 month ago

I know, it's not native mqtt, but you can already use mqtt via the RabbitMQ MQTT Plugin.