liveBook · Manning

ConfigDef

As explained in Kafka Streams in Action, Second Edition

ConfigDef is a Kafka Connect API class that defines the names, types, defaults, and validation rules for connector configurations.

ConfigDef declares the configuration contract for a Kafka Connect connector. A connector builds it fluently with define calls so Kafka Connect knows expected settings such as an API URL and destination topic. section 5.6.1

Listing 5.5 Setting up a ConfigDef instance
public class StockTickerSourceConnector extends SourceConnector {
private static final ConfigDef CONFIG_DEF = new ConfigDef() #1
            .define(API_URL_CONFIG,          #2
                   ConfigDef.Type.STRING,
                   ConfigDef.Importance.HIGH,
                   "URL for the desired API call")
            .define(TOPIC_CONFIG,     #3
                   ConfigDef.Type.STRING,
                   ConfigDef.Importance.HIGH,
                   "The topic to publish data to")

... followed by the rest of the configurations
}

See a concrete StockTickerSourceConnector declaration chaining define calls for configuration names, string types, importance levels, and descriptions. section 5.6.1

Use the definition to shape connector startup and task configuration:

  • Provide defaults through define; omitted settings receive those values. section 5.6.1
  • Omit a required setting without a default and startup throws ConfigException, shutting down the connector. section 5.6.1
  • Use the resulting connector settings when creating per-task maps, including grouped ticker symbols, topic, URL, token, and batch size. section 5.6.1

How Kafka Streams in Action, Second Edition covers it

How deep it goes
Explains fluent definitions, defaults, and missing-setting failures, but does not show the complete configuration declaration.
Examples
Uses a stock ticker connector configured with an API URL, Kafka topic, and grouped ticker symbols.
What you can do after
Builds a connector configuration definition and recognizes how omitted settings affect startup.
How it connects
Links connector configuration with SourceConnector, Task, taskConfigs, and ConfigException.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kafka Streams in Action, Second Edition. The section links point to the parts of the book it draws on.