Add KafkaAdmin Auto Configuration

Spring for Apache Kafka has added a `KafkaAdmin` feature to automatically
add new topics to the broker.

See gh-10309
This commit is contained in:
Gary Russell
2017-09-15 12:25:55 -04:00
committed by Stephane Nicoll
parent c7eb0fb281
commit 3e1d9fa856
6 changed files with 173 additions and 1 deletions

View File

@@ -939,6 +939,15 @@ content into your application; rather pick only the properties that you need.
spring.jms.template.time-to-live= # Time-to-live of a message when sending in milliseconds. Enable QoS when set.
# APACHE KAFKA ({sc-spring-boot-autoconfigure}/kafka/KafkaProperties.{sc-ext}[KafkaProperties])
spring.kafka.admin.bootstrap-servers= # Comma-delimited list of host:port pairs to use for establishing the initial connection to the Kafka cluster.
spring.kafka.admin.client-id= # Id to pass to the server when making requests; used for server-side logging.
spring.kafka.admin.fail-if-no-brokers=false # When true, the application context will not load if the broker connection fails when attempting to provision topics.
spring.kafka.admin.properties.*= # Additional admin-specific properties used to configure the client.
spring.kafka.admin.ssl.key-password= # Password of the private key in the key store file.
spring.kafka.admin.ssl.keystore-location= # Location of the key store file.
spring.kafka.admin.ssl.keystore-password= # Store password for the key store file.
spring.kafka.admin.ssl.truststore-location= # Location of the trust store file.
spring.kafka.admin.ssl.truststore-password= # Store password for the trust store file.
spring.kafka.bootstrap-servers= # Comma-delimited list of host:port pairs to use for establishing the initial connection to the Kafka cluster.
spring.kafka.client-id= # Id to pass to the server when making requests; used for server-side logging.
spring.kafka.consumer.auto-commit-interval= # Frequency in milliseconds that the consumer offsets are auto-committed to Kafka if 'enable.auto.commit' true.

View File

@@ -4821,6 +4821,15 @@ for more of the supported options.
[[boot-features-kafka-topics]]
==== Creating Topics
Spring Boot auto configuration will add a `KafkaAdmin` bean to the application context.
This bean will automatically create a topic for each `NewTopic` bean in the application context.
Topics can only be added with this technique, not modified; if a topic already exists, the `NewTopic` bean is ignored.
[[boot-features-kafka-sending-a-message]]
==== Sending a Message
Spring's `KafkaTemplate` is auto-configured and you can autowire them directly in your own