Skip to content

Commit 0ddff6d

Browse files
committed
Add BeanNameAware to Producer/Consumer Factories
Resolves spring-attic/spring-cloud-stream-binder-kafka#930 Re-enable Hoxton to be used with Spring Boot 2.2.x.
1 parent db306bf commit 0ddff6d

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

spring-kafka/src/main/java/org/springframework/kafka/core/DefaultKafkaConsumerFactory.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.apache.kafka.clients.consumer.KafkaConsumer;
2929
import org.apache.kafka.common.serialization.Deserializer;
3030

31+
import org.springframework.beans.factory.BeanNameAware;
3132
import org.springframework.core.log.LogAccessor;
3233
import org.springframework.lang.Nullable;
3334
import org.springframework.util.StringUtils;
@@ -57,7 +58,7 @@
5758
* @author Artem Bilan
5859
* @author Chris Gilbert
5960
*/
60-
public class DefaultKafkaConsumerFactory<K, V> implements ConsumerFactory<K, V> {
61+
public class DefaultKafkaConsumerFactory<K, V> implements ConsumerFactory<K, V>, BeanNameAware {
6162

6263
private static final LogAccessor LOGGER = new LogAccessor(LogFactory.getLog(DefaultKafkaConsumerFactory.class));
6364

@@ -104,6 +105,10 @@ public DefaultKafkaConsumerFactory(Map<String, Object> configs,
104105
this.valueDeserializerSupplier = valueDeserializerSupplier == null ? () -> null : valueDeserializerSupplier;
105106
}
106107

108+
@Override
109+
public void setBeanName(String name) {
110+
}
111+
107112
public void setKeyDeserializer(@Nullable Deserializer<K> keyDeserializer) {
108113
this.keyDeserializerSupplier = () -> keyDeserializer;
109114
}

spring-kafka/src/main/java/org/springframework/kafka/core/DefaultKafkaProducerFactory.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import org.apache.kafka.common.serialization.Serializer;
5151

5252
import org.springframework.beans.BeansException;
53+
import org.springframework.beans.factory.BeanNameAware;
5354
import org.springframework.beans.factory.DisposableBean;
5455
import org.springframework.context.ApplicationContext;
5556
import org.springframework.context.ApplicationContextAware;
@@ -107,7 +108,7 @@
107108
* @author Chris Gilbert
108109
*/
109110
public class DefaultKafkaProducerFactory<K, V> implements ProducerFactory<K, V>, ApplicationContextAware,
110-
ApplicationListener<ContextStoppedEvent>, DisposableBean {
111+
BeanNameAware, ApplicationListener<ContextStoppedEvent>, DisposableBean {
111112

112113
/**
113114
* The default close timeout duration as 30 seconds.
@@ -208,6 +209,9 @@ public DefaultKafkaProducerFactory(Map<String, Object> configs,
208209
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
209210
this.applicationContext = applicationContext;
210211
}
212+
@Override
213+
public void setBeanName(String name) {
214+
}
211215

212216
public void setKeySerializer(@Nullable Serializer<K> keySerializer) {
213217
this.keySerializerSupplier = () -> keySerializer;

0 commit comments

Comments
 (0)