Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when creating a topic using aiokafka 0.11.0 #630

Closed
hgalytoby opened this issue Jul 2, 2024 · 5 comments · Fixed by #631
Closed

Error when creating a topic using aiokafka 0.11.0 #630

hgalytoby opened this issue Jul 2, 2024 · 5 comments · Fixed by #631

Comments

@hgalytoby
Copy link
Contributor

poetry add faust-stream

import faust


class Greeting(faust.Record):
    from_name: str
    to_name: str


app = faust.App('hello-app', broker='kafka://localhost')
topic = app.topic('hello-topic', value_type=Greeting)


@app.agent(topic)
async def hello(greetings):
    async for greeting in greetings:
        print(f'Hello from {greeting.from_name} to {greeting.to_name}')


@app.timer(interval=1.0)
async def example_sender(app):
    await hello.send(
        value=Greeting(from_name='Faust', to_name='you'),
    )


if __name__ == '__main__':
    app.main()

error

AttributeError: 'CreateTopicsRequest_v1' object has no attribute 'build_request_header'

No problems with aiokafka 0.10.0

@fonty422
Copy link
Collaborator

fonty422 commented Jul 3, 2024

Do you need the Faust application to create the topic? Can you try to add the topic manually with the Kafka topic scripts and see if that helps?

@hgalytoby
Copy link
Contributor Author

Usually I don't need faust to create a topic, usually faust just creates the leader topic for me.

I know there are other ways to create topics, it's just a matter of me finding out about it and letting it be known!

@fonty422
Copy link
Collaborator

fonty422 commented Jul 4, 2024

I have an issue with my applications where if I use Faust to create the topics it often results in a topic not being created (something about topic can't be used while being created) and then the error message ignoring missing topic: . I think this is due to a large volume of applications being started at the same time and the CPU is wildly overloaded.

To get around this, I manually create the topics before hand using the kafka_topics.sh (or .bat if using windows) that's part of your kafka download and found in the bin directory.

For me, when ever I start my application I first run:
kafka-topics.sh --create --if-not-exists --topic <topic name> --bootstrap-server=<address> --partitions=<partitions>
replacing topic name, address, and partitions with the appropriate values.

The --if-not-exists argument will only create the topic if it doesn't already exist.

@jjwwiodyne
Copy link

I'm seeing the same issue with the combination of faust 0.11.0 and aiokafka 0.10.0. Forcing aiokafka==0.10.0 fixes the issue.

@somnam
Copy link
Contributor

somnam commented Jul 9, 2024

Added a PR for this #631, can someone have a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants