This tool generates base64-encoded serialized products for testing the Kafka consumer functions with different serialization formats.
- JSON: Generates base64-encoded JSON serialized products
- Avro: Generates base64-encoded Avro serialized products
- Protobuf: Generates base64-encoded Protobuf serialized products
Run the following Maven commands from this directory:
# Generate Avro and Protobuf classes from schemas
mvn generate-sources
# Compile the code
mvn compile# Run the JSON sample generator
mvn exec:java -Dexec.mainClass="org.demo.kafka.tools.GenerateJsonSamples"The tool will output base64-encoded values for JSON products that can be used in ../events/kafka-json-event.json.
# Run the Avro sample generator
mvn exec:java -Dexec.mainClass="org.demo.kafka.tools.GenerateAvroSamples"The tool will output base64-encoded values for Avro products that can be used in ../events/kafka-avro-event.json.
# Run the Protobuf sample generator
mvn exec:java -Dexec.mainClass="org.demo.kafka.tools.GenerateProtobufSamples"The tool will output base64-encoded values for Protobuf products that can be used in ../events/kafka-protobuf-event.json.
Each generator produces:
- Three different products (Laptop, Smartphone, Headphones)
- An integer key (42) and one entry with a nullish key to test for edge-cases
- A complete sample event structure that can be used directly for testing
After generating the samples, you can copy the output into the respective event files:
../events/kafka-json-event.jsonfor JSON samples../events/kafka-avro-event.jsonfor Avro samples../events/kafka-protobuf-event.jsonfor Protobuf samples
These event files can then be used to test the Lambda functions with the appropriate deserializer.