From a997740c298c28baa254ab9625235167bc1f71d3 Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Tue, 23 Jan 2018 16:33:48 -0500 Subject: [PATCH] More Lifecycle Polishing - `null` the consumer on `stop()` - set `running` to true on first receive if needed --- .../integration/kafka/inbound/KafkaMessageSource.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spring-integration-kafka/src/main/java/org/springframework/integration/kafka/inbound/KafkaMessageSource.java b/spring-integration-kafka/src/main/java/org/springframework/integration/kafka/inbound/KafkaMessageSource.java index b4e1ad67db..666586b6e3 100644 --- a/spring-integration-kafka/src/main/java/org/springframework/integration/kafka/inbound/KafkaMessageSource.java +++ b/spring-integration-kafka/src/main/java/org/springframework/integration/kafka/inbound/KafkaMessageSource.java @@ -262,6 +262,7 @@ public class KafkaMessageSource extends AbstractMessageSource synchronized (this.consumerMonitor) { if (this.consumer != null) { this.consumer.close(30, TimeUnit.SECONDS); + this.consumer = null; } } this.running = false; @@ -307,8 +308,8 @@ public class KafkaMessageSource extends AbstractMessageSource } protected void createConsumer() { - this.consumer = this.consumerFactory.createConsumer(this.groupId, this.clientId, null); synchronized (this.consumerMonitor) { + this.consumer = this.consumerFactory.createConsumer(this.groupId, this.clientId, null); this.consumer.subscribe(Arrays.asList(this.topics), new ConsumerRebalanceListener() { @Override @@ -332,6 +333,7 @@ public class KafkaMessageSource extends AbstractMessageSource } }); + this.running = true; } }