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
