FastStream provides a Message Broker agnostic way to subscribe to event streams.
You need not even know about topics/queues/subjects or any broker inner objects you use. The basic syntax is the same for all brokers:
If you want to use Message Broker specific features, please visit the corresponding broker documentation section. In the Tutorial section, the general features are described.
Also, synchronous functions are supported as well:
Message Body Serialization#
However, you can easily disable Pydantic validation by creating a broker with the following option
Broker(apply_types=False) (this also disables Context and Depends features).
This way FastStream still consumes
json.loads result, but without pydantic validation and casting.
You can also subscribe to multiple event streams at the same time with one function. Just wrap it with multiple
@broker.subscriber(...) decorators (they have no effect on each other).