Description
Kafka provided some examples under "examples" package. Currently we provided
- java-producer-consumer-demo, which is to produce 10000 records and then consume all of them
- exactly-once-demo, which is to produce records -> consume -> process -> consume.
Among them, the base component is producer and consumer. However, I found the producer and consumer example is not in a good form. For example:
- Both consumer and producer doesn't gracefully close the resource after completed
- The example doesn't provide a good example to handle different kind of exceptions. It's just a happy path example
- No clear comment to instruct users why we should do this, and what it is doing for each operation.
Furthermore, while running both the examples, I saw flood of logs output because we print one line for message sent, and one line for message received. In java-producer-consumer-demo, there will be 10000 records sent/received, so > 20000 lines of logs output. Same for exactly-once-demo. Maybe we should consider to reduce the record number.
One more thing, in exactly-once-demo.java, there are clear class java doc in the demo file, but there's nothing in java-producer-consumer-demo.java. We should also improve that.