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

provide builders for producer/consumer

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • clients
    • None

    Description

      creating a producer/consumer involves looking up the consts for kafka configuration, and usually doing a lot of googling for what the possible values are for each configuration. Providing a builder where there are named methods to set various configuration, with meaningful parameters (ie: enums for configurations that can only have a few values), and good javadoc would make it much easier from developers working from ides (such as intellij, eclipse, netbeans, etc) to discover the various configurations, and navigate to the documentation for the various options when creating producers/consumers.

      Examples:

      Pseudocode:

      Producer:

       

      ProducerBuilder(String bootstrapUrl)
      { ... }
      ProducerBuilder withTransactionsEnabled(String transactionalId){ ... // internally sets a flag so that transactions are initialized when producer is built }
      Producer build(){ ... }
      
      
      

       

      Salient Consumer Example:

      /**
      *
      * @param strategy : if the strategy is set to NONE, then an error is thrown if a valid offset is passed to seek (etc.), if it is set to EARLIEST, then the consumer will seek to beginning (etc).
      */
      ConsumerBuilder withAutoOffsetResetStrategy(OffsetResetStrategy strategy){ ... } 

       

      where OffsetResetStrategy is an enum with 3 values 

      public enum OffsetResetStrategy {EARLIEST,LATEST, NONE}

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              scanteianu Daniel Scanteianu
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: