Skip to content

Commit 11ab2d7

Browse files
committed
Add configuration property for leaveGroupOnClose in Kafka Streams
This makes it possible to set the option to leave the group on close at configuration/deployment time in the application properties. Signed-off-by: Trygve Aasjord <taasjord@users.noreply.github.com>
1 parent a329d70 commit 11ab2d7

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

module/spring-boot-kafka/src/main/java/org/springframework/boot/kafka/autoconfigure/KafkaProperties.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,11 @@ public static class Streams {
812812
*/
813813
private @Nullable String stateDir;
814814

815+
/**
816+
* Whether the consumer should leave the group when stopping Kafka Streams.
817+
*/
818+
private boolean leaveGroupOnClose;
819+
815820
/**
816821
* Additional Kafka properties used to configure the streams.
817822
*/
@@ -885,6 +890,14 @@ public void setStateDir(@Nullable String stateDir) {
885890
this.stateDir = stateDir;
886891
}
887892

893+
public boolean isLeaveGroupOnClose() {
894+
return this.leaveGroupOnClose;
895+
}
896+
897+
public void setLeaveGroupOnClose(boolean leaveGroupOnClose) {
898+
this.leaveGroupOnClose = leaveGroupOnClose;
899+
}
900+
888901
public Map<String, String> getProperties() {
889902
return this.properties;
890903
}

module/spring-boot-kafka/src/main/java/org/springframework/boot/kafka/autoconfigure/KafkaStreamsAnnotationDrivenConfiguration.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ public void configure(StreamsBuilderFactoryBean factoryBean) {
101101
KafkaProperties.Cleanup cleanup = this.properties.getStreams().getCleanup();
102102
CleanupConfig cleanupConfig = new CleanupConfig(cleanup.isOnStartup(), cleanup.isOnShutdown());
103103
factoryBean.setCleanupConfig(cleanupConfig);
104+
factoryBean.setLeaveGroupOnClose(this.properties.getStreams().isLeaveGroupOnClose());
104105
}
105106

106107
@Override

0 commit comments

Comments
 (0)