Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-14752

improve kafka examples under examples package

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 3.6.0
    • None

    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:

      1. Both consumer and producer doesn't gracefully close the resource after completed
      2. The example doesn't provide a good example to handle different kind of exceptions. It's just a happy path example
      3. 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.

       

       

       

      Attachments

        Issue Links

          Activity

            People

              fvaleri Federico Valeri
              showuon Luke Chen
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: