diff --git a/basic/kafka/src/main/java/org/springframework/integration/samples/kafka/Application.java b/basic/kafka/src/main/java/org/springframework/integration/samples/kafka/Application.java index d69d5b34..48a30e7d 100644 --- a/basic/kafka/src/main/java/org/springframework/integration/samples/kafka/Application.java +++ b/basic/kafka/src/main/java/org/springframework/integration/samples/kafka/Application.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2017 the original author or authors. + * Copyright 2015-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ package org.springframework.integration.samples.kafka; import java.util.Collections; import java.util.Map; +import org.apache.kafka.clients.admin.NewTopic; import org.apache.kafka.clients.consumer.ConsumerConfig; import org.apache.kafka.clients.producer.ProducerConfig; @@ -150,6 +151,20 @@ public class Application { return new QueueChannel(); } + /* + * Boot's autoconfigured KafkaAdmin will provision the topics. + */ + + @Bean + public NewTopic topic(KafkaAppProperties properties) { + return new NewTopic(properties.getTopic(), 1, (short) 1); + } + + @Bean + public NewTopic newTopic(KafkaAppProperties properties) { + return new NewTopic(properties.getNewTopic(), 1, (short) 1); + } + @Autowired private IntegrationFlowContext flowContext; diff --git a/dsl/kafka-dsl/src/main/java/org/springframework/integration/samples/dsl/kafka/Application.java b/dsl/kafka-dsl/src/main/java/org/springframework/integration/samples/dsl/kafka/Application.java index 89ac9d4f..3261f64f 100644 --- a/dsl/kafka-dsl/src/main/java/org/springframework/integration/samples/dsl/kafka/Application.java +++ b/dsl/kafka-dsl/src/main/java/org/springframework/integration/samples/dsl/kafka/Application.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2017 the original author or authors. + * Copyright 2016-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package org.springframework.integration.samples.dsl.kafka; import java.util.Map; +import org.apache.kafka.clients.admin.NewTopic; import org.apache.kafka.clients.consumer.ConsumerConfig; import org.springframework.beans.factory.annotation.Autowired; @@ -115,6 +116,20 @@ public class Application { .get(); } + /* + * Boot's autoconfigured KafkaAdmin will provision the topics. + */ + + @Bean + public NewTopic topic(KafkaAppProperties properties) { + return new NewTopic(properties.getTopic(), 1, (short) 1); + } + + @Bean + public NewTopic newTopic(KafkaAppProperties properties) { + return new NewTopic(properties.getNewTopic(), 1, (short) 1); + } + @Autowired private IntegrationFlowContext flowContext;