diff --git a/spring-cloud-stream-binder-kafka-streams/src/main/java/org/springframework/cloud/stream/binder/kafka/streams/GlobalKTableBinderConfiguration.java b/spring-cloud-stream-binder-kafka-streams/src/main/java/org/springframework/cloud/stream/binder/kafka/streams/GlobalKTableBinderConfiguration.java index 35e12240d..9153f0d86 100644 --- a/spring-cloud-stream-binder-kafka-streams/src/main/java/org/springframework/cloud/stream/binder/kafka/streams/GlobalKTableBinderConfiguration.java +++ b/spring-cloud-stream-binder-kafka-streams/src/main/java/org/springframework/cloud/stream/binder/kafka/streams/GlobalKTableBinderConfiguration.java @@ -39,8 +39,8 @@ import org.springframework.context.annotation.Import; */ @Configuration @Import({ KafkaAutoConfiguration.class, - KafkaStreamsBinderHealthIndicatorConfiguration.class, - MultiBinderPropertiesConfiguration.class}) + MultiBinderPropertiesConfiguration.class, + KafkaStreamsBinderHealthIndicatorConfiguration.class}) public class GlobalKTableBinderConfiguration { @Bean @@ -81,6 +81,9 @@ public class GlobalKTableBinderConfiguration { beanFactory.registerSingleton( KafkaStreamsBindingInformationCatalogue.class.getSimpleName(), outerContext.getBean(KafkaStreamsBindingInformationCatalogue.class)); + beanFactory.registerSingleton( + KafkaStreamsRegistry.class.getSimpleName(), + outerContext.getBean(KafkaStreamsRegistry.class)); }; } diff --git a/spring-cloud-stream-binder-kafka-streams/src/main/java/org/springframework/cloud/stream/binder/kafka/streams/KStreamBinderConfiguration.java b/spring-cloud-stream-binder-kafka-streams/src/main/java/org/springframework/cloud/stream/binder/kafka/streams/KStreamBinderConfiguration.java index 254bfb534..21de23e30 100644 --- a/spring-cloud-stream-binder-kafka-streams/src/main/java/org/springframework/cloud/stream/binder/kafka/streams/KStreamBinderConfiguration.java +++ b/spring-cloud-stream-binder-kafka-streams/src/main/java/org/springframework/cloud/stream/binder/kafka/streams/KStreamBinderConfiguration.java @@ -37,8 +37,8 @@ import org.springframework.context.annotation.Import; */ @Configuration @Import({ KafkaAutoConfiguration.class, - KafkaStreamsBinderHealthIndicatorConfiguration.class, - MultiBinderPropertiesConfiguration.class}) + MultiBinderPropertiesConfiguration.class, + KafkaStreamsBinderHealthIndicatorConfiguration.class}) public class KStreamBinderConfiguration { @Bean @@ -86,6 +86,9 @@ public class KStreamBinderConfiguration { beanFactory.registerSingleton( KafkaStreamsExtendedBindingProperties.class.getSimpleName(), outerContext.getBean(KafkaStreamsExtendedBindingProperties.class)); + beanFactory.registerSingleton( + KafkaStreamsRegistry.class.getSimpleName(), + outerContext.getBean(KafkaStreamsRegistry.class)); }; } diff --git a/spring-cloud-stream-binder-kafka-streams/src/main/java/org/springframework/cloud/stream/binder/kafka/streams/KTableBinderConfiguration.java b/spring-cloud-stream-binder-kafka-streams/src/main/java/org/springframework/cloud/stream/binder/kafka/streams/KTableBinderConfiguration.java index 4281bf653..0ef9fa6e0 100644 --- a/spring-cloud-stream-binder-kafka-streams/src/main/java/org/springframework/cloud/stream/binder/kafka/streams/KTableBinderConfiguration.java +++ b/spring-cloud-stream-binder-kafka-streams/src/main/java/org/springframework/cloud/stream/binder/kafka/streams/KTableBinderConfiguration.java @@ -39,8 +39,8 @@ import org.springframework.context.annotation.Import; @SuppressWarnings("ALL") @Configuration @Import({ KafkaAutoConfiguration.class, - KafkaStreamsBinderHealthIndicatorConfiguration.class, - MultiBinderPropertiesConfiguration.class}) + MultiBinderPropertiesConfiguration.class, + KafkaStreamsBinderHealthIndicatorConfiguration.class}) public class KTableBinderConfiguration { @Bean @@ -79,6 +79,9 @@ public class KTableBinderConfiguration { beanFactory.registerSingleton( KafkaStreamsBindingInformationCatalogue.class.getSimpleName(), outerContext.getBean(KafkaStreamsBindingInformationCatalogue.class)); + beanFactory.registerSingleton( + KafkaStreamsRegistry.class.getSimpleName(), + outerContext.getBean(KafkaStreamsRegistry.class)); }; } diff --git a/spring-cloud-stream-binder-kafka-streams/src/main/java/org/springframework/cloud/stream/binder/kafka/streams/KafkaStreamsBinderHealthIndicatorConfiguration.java b/spring-cloud-stream-binder-kafka-streams/src/main/java/org/springframework/cloud/stream/binder/kafka/streams/KafkaStreamsBinderHealthIndicatorConfiguration.java index 46a7c2c1e..55ecf2b03 100644 --- a/spring-cloud-stream-binder-kafka-streams/src/main/java/org/springframework/cloud/stream/binder/kafka/streams/KafkaStreamsBinderHealthIndicatorConfiguration.java +++ b/spring-cloud-stream-binder-kafka-streams/src/main/java/org/springframework/cloud/stream/binder/kafka/streams/KafkaStreamsBinderHealthIndicatorConfiguration.java @@ -16,9 +16,9 @@ package org.springframework.cloud.stream.binder.kafka.streams; +import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.kafka.KafkaProperties; import org.springframework.cloud.stream.binder.kafka.streams.properties.KafkaStreamsBinderConfigurationProperties; @@ -36,13 +36,15 @@ import org.springframework.context.annotation.Configuration; class KafkaStreamsBinderHealthIndicatorConfiguration { @Bean - @ConditionalOnBean(KafkaStreamsRegistry.class) KafkaStreamsBinderHealthIndicator kafkaStreamsBinderHealthIndicator( - KafkaStreamsRegistry kafkaStreamsRegistry, @Qualifier("binderConfigurationProperties")KafkaStreamsBinderConfigurationProperties kafkaStreamsBinderConfigurationProperties, + ObjectProvider kafkaStreamsRegistry, + @Qualifier("binderConfigurationProperties")KafkaStreamsBinderConfigurationProperties kafkaStreamsBinderConfigurationProperties, KafkaProperties kafkaProperties, KafkaStreamsBindingInformationCatalogue kafkaStreamsBindingInformationCatalogue) { - - return new KafkaStreamsBinderHealthIndicator(kafkaStreamsRegistry, kafkaStreamsBinderConfigurationProperties, - kafkaProperties, kafkaStreamsBindingInformationCatalogue); + if (kafkaStreamsRegistry.getIfUnique() != null) { + return new KafkaStreamsBinderHealthIndicator(kafkaStreamsRegistry.getIfUnique(), kafkaStreamsBinderConfigurationProperties, + kafkaProperties, kafkaStreamsBindingInformationCatalogue); + } + return null; } } diff --git a/spring-cloud-stream-binder-kafka-streams/src/main/java/org/springframework/cloud/stream/binder/kafka/streams/MultiBinderPropertiesConfiguration.java b/spring-cloud-stream-binder-kafka-streams/src/main/java/org/springframework/cloud/stream/binder/kafka/streams/MultiBinderPropertiesConfiguration.java index 176577f85..466cfdf37 100644 --- a/spring-cloud-stream-binder-kafka-streams/src/main/java/org/springframework/cloud/stream/binder/kafka/streams/MultiBinderPropertiesConfiguration.java +++ b/spring-cloud-stream-binder-kafka-streams/src/main/java/org/springframework/cloud/stream/binder/kafka/streams/MultiBinderPropertiesConfiguration.java @@ -34,7 +34,7 @@ public class MultiBinderPropertiesConfiguration { @Bean @ConfigurationProperties(prefix = "spring.cloud.stream.kafka.streams.binder") @ConditionalOnBean(name = "outerContext") - public KafkaBinderConfigurationProperties kafkaBinderConfigurationProperties(KafkaProperties kafkaProperties) { + public KafkaBinderConfigurationProperties binderConfigurationProperties(KafkaProperties kafkaProperties) { return new KafkaStreamsBinderConfigurationProperties(kafkaProperties); } }