Add Kafka Stream's leaveGroupOnClose property

This commit makes it possible to set the option to leave the group on
close at configuration/deployment time using configuration.

See gh-50432

Signed-off-by: Trygve Aasjord <taasjord@users.noreply.github.com>
This commit is contained in:
Trygve Aasjord
2026-07-16 11:37:14 +02:00
committed by Stéphane Nicoll
parent 42e725db10
commit becdfefbed
2 changed files with 14 additions and 0 deletions
@@ -812,6 +812,11 @@ public class KafkaProperties {
*/
private @Nullable String stateDir;
/**
* Whether the consumer should leave the group when stopping Kafka Streams.
*/
private boolean leaveGroupOnClose;
/**
* Additional Kafka properties used to configure the streams.
*/
@@ -885,6 +890,14 @@ public class KafkaProperties {
this.stateDir = stateDir;
}
public boolean isLeaveGroupOnClose() {
return this.leaveGroupOnClose;
}
public void setLeaveGroupOnClose(boolean leaveGroupOnClose) {
this.leaveGroupOnClose = leaveGroupOnClose;
}
public Map<String, String> getProperties() {
return this.properties;
}
@@ -101,6 +101,7 @@ class KafkaStreamsAnnotationDrivenConfiguration {
KafkaProperties.Cleanup cleanup = this.properties.getStreams().getCleanup();
CleanupConfig cleanupConfig = new CleanupConfig(cleanup.isOnStartup(), cleanup.isOnShutdown());
factoryBean.setCleanupConfig(cleanupConfig);
factoryBean.setLeaveGroupOnClose(this.properties.getStreams().isLeaveGroupOnClose());
}
@Override