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

Add getter for KafkaConsumer configs

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: clients
    • Labels:
      None

      Description

      Given a KafkaConsumer, there is currently no way to inspect the config that it was instantiated with. This is a problem when building abstractions around KafkaConsumer instances that only accept certain configurations.

      For example, if you want to build a reusable poll loop helper that manually handles committing offsets, the default value for enable.auto.commit (true) will silently cause unexpected behavior in offset committing. The only two options for preventing that bug right now are to add a big comment to the helper's doc or to have the helper construct its own KafkaConsumer. The latter is unsavory because it's an unsafe-by-default design, and the latter unnecessarily restricts the possible configurations a KafkaConsumer can be in. The helper could take a list of topics to subscribe to, but what if the helper's user wants to use assign rather than subscribe?

      As a straw man, I propose the following method be added to KafkaConsumer:

      Object getProperty(String key)

      It would simply return the corresponding value from the KafkaConsumer instance's ConsumerConfig.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              max.rothman Max Rothman
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: