-
I'm trying to figure out how to encapsulate the broker into a class. I noticed most of the examples are written in a way that assumes you will be using the Is something like this supported? from faststream import FastStream
from faststream.annotations import Logger
from faststream.rabbit import RabbitBroker
class Consumer:
def __init__(self):
self.broker = RabbitBroker("amqp://guest:guest@localhost:5672/")
self.app = FastStream(broker)
@self.broker.subscriber("test-queue")
async def handle(msg, logger: Logger):
logger.info(msg)
async consume(self):
await self.app.run() Is there a way to pass a consumer callback function to the broker without using a decorator? Because of the decorator I can't use @self.broker as a regular function. I'm not sure/can't find in the docs what's the correct way starting/doing something like this? Do I need to call |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
You can declare subscribers anywhere with router and include them to broker lately |
Beta Was this translation helpful? Give feedback.
You can declare subscribers anywhere with router and include them to broker lately
https://faststream.airt.ai/latest/getting-started/routers/