Replies: 1 comment
-
👋 Hello @YozEllon ! Regarding FastKafka Deprecated: Multiple Producers and FastStream: Persistent Connection in the Whole Program: from fastapi import FastAPI
from kafka import to_output_data, kafka_app
app = FastAPI(lifespan=kafka_app.fastapi_lifespan("localhost"))
@fastapi_app.get("/")
async def root():
await to_output_data(1.0) By incorporating FastAPI lifespan events, you can efficiently manage the lifecycle of your FastKafka instance, maintaining a persistent connection throughout the program. For more detailed information, you can refer to the FastStream guide on using FastAPI to run FastKafka applications. Or, if transitioning to FastStream, take a look at This guide on how to integrate with FastAPI Feel free to reach out if you have any further questions or need additional clarification! 🚀 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone 👋
1- When I was checking the codes related to produces decorator, I noticed that for each topic, an instance is created separately from AIOKafkaProducer and every time it is done using the object related to the produce topic, can I know the reason? Why don't we use one instance for all topics?
2- When we want to use the producers defined directly in the app, a connection is opened and closed every time, isn't it better to have one open connection in the whole program?
main.py
Beta Was this translation helpful? Give feedback.
All reactions