- This uses the python loremipsum generator. You can replace
g.generate_sentence()with your own string or generator of choice - Make sure to replace
schema_pathin the script with your own schema path - No guarantees that this is the best way to loop over records and publish them to Kafka, just a demo. Before adapting this script, take a look at the Avro documentation...the writer might not need to be instantiated for every record, for example. I'm just not sure.
- Create a Kafka topic to test this on (default in the script is 'test')
- Replace
schema_pathwith the path touser.avsc - Open up a console Kafka consumer (see the 'quick start' section in Kafka's documentation)
- From the command line,
python kafka_avro_python_example.py - Because the records are Avro-encoded, you'll see some funky characters in the console consumer. This is expected.
how to tell which partition your data is sent to?