You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I'm trying to use this package for the first time and I have a question
I declared two Kafka consumers (and two partitions), but only one of them is ready to listen (see logs and code below).
Is there a way to fix this so that an arbitrary number of consumers work within one process? (as in my case it is a process running uvicorn+fastapi)
Consumers code:
fromfunctoolsimportpartialfromfaststream.kafkaimportKafkaMessagefrompydanticimportBaseModelfromdepsimportkafka_client# .kafka field - it's object of KafkaBroker type which is taken from FastStreamconsumer_group=partial(
kafka_client.kafka.subscriber,
"test_topic",
group_id="gr",
auto_commit=False,
)
classMessage(BaseModel): ...
@consumer_group()asyncdefconsumer(message: Message, msg: KafkaMessage):
print(f"Got message: {message}")
@consumer_group(batch=True)asyncdefanother_consumer(msgs: list[Message], msg: KafkaMessage):
print(f"Got batch message")
Logs with this code:
INFO: Uvicorn running on http://0.0.0.0:8099 (Press CTRL+C to quit)
INFO: Started reloader process [30176] using StatReload
INFO: Started server process [30178]
INFO: Waiting for application startup.
2025-01-29 15:13:06,164 INFO - test_topic | gr | - `Consumer` waiting for messages
Case with commented first consumer
If i comment code with first consumer (consumer function) then i get next logs:
INFO: Uvicorn running on http://0.0.0.0:8099 (Press CTRL+C to quit)
INFO: Started reloader process [30355] using StatReload
INFO: Started server process [30360]
INFO: Waiting for application startup.
2025-01-29 15:16:26,309 INFO - test_topic | gr | - `AnotherConsumer` waiting for messages
P.S. code with consumers located in package kafka_.consumer and when the application starts I import everything from this file:
fromkafka_.consumerimport*
The text was updated successfully, but these errors were encountered:
Description
Hi! I'm trying to use this package for the first time and I have a question
I declared two Kafka consumers (and two partitions), but only one of them is ready to listen (see logs and code below).
Is there a way to fix this so that an arbitrary number of consumers work within one process? (as in my case it is a process running uvicorn+fastapi)
Consumers code:
Logs with this code:
Case with commented first consumer
If i comment code with first consumer (
consumer
function) then i get next logs:P.S. code with consumers located in package
kafka_.consumer
and when the application starts I import everything from this file:The text was updated successfully, but these errors were encountered: