More Lifecycle Polishing
- `null` the consumer on `stop()` - set `running` to true on first receive if needed
This commit is contained in:
committed by
Artem Bilan
parent
28b4dd814c
commit
a997740c29
@@ -262,6 +262,7 @@ public class KafkaMessageSource<K, V> extends AbstractMessageSource<Object>
|
||||
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<K, V> extends AbstractMessageSource<Object>
|
||||
}
|
||||
|
||||
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<K, V> extends AbstractMessageSource<Object>
|
||||
}
|
||||
|
||||
});
|
||||
this.running = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user