Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.springframework.boot.context.properties.PropertyMapper;
import org.springframework.boot.convert.DurationUnit;
import org.springframework.core.io.Resource;
import org.springframework.kafka.core.CleanupConfig;
import org.springframework.kafka.listener.ContainerProperties.AckMode;
import org.springframework.kafka.security.jaas.KafkaJaasLoginModuleInitializer;
import org.springframework.util.CollectionUtils;
Expand Down Expand Up @@ -722,6 +723,11 @@ public static class Streams {
*/
private String stateDir;

/**
* Cleanup configuration for the state stores.
*/
private Cleanup cleanup;

/**
* Additional Kafka properties used to configure the streams.
*/
Expand Down Expand Up @@ -791,6 +797,14 @@ public void setStateDir(String stateDir) {
this.stateDir = stateDir;
}

public Cleanup getCleanup() {
return cleanup;
}

public void setCleanup(Cleanup cleanup) {
this.cleanup = cleanup;
}

public Map<String, String> getProperties() {
return this.properties;
}
Expand Down Expand Up @@ -1259,6 +1273,32 @@ public byte id() {

}

public static class Cleanup {

/**
* Cleanup the application's state on start.
*/
private boolean onStart = false;

/**
* Cleanup the application's state on stop.
*/
private boolean onStop = true;

public CleanupConfig buildCleanupConfig() {
return new CleanupConfig(this.onStart, this.onStop);
}

public boolean isOnStart() {
return onStart;
}

public boolean isOnStop() {
return onStop;
}

}

@SuppressWarnings("serial")
private static class Properties extends HashMap<String, Object> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ static class KafkaStreamsFactoryBeanConfigurer implements InitializingBean {
@Override
public void afterPropertiesSet() {
this.factoryBean.setAutoStartup(this.properties.getStreams().isAutoStartup());

KafkaProperties.Cleanup cleanup = this.properties.getStreams().getCleanup();
if (cleanup != null) {
this.factoryBean.setCleanupConfig(cleanup.buildCleanupConfig());
}
}

}
Expand Down
2 changes: 1 addition & 1 deletion spring-boot-project/spring-boot-dependencies/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -1588,7 +1588,7 @@ bom {
]
}
}
library("Spring Kafka", "2.6.1") {
library("Spring Kafka", "2.6.2-SNAPSHOT") {
group("org.springframework.kafka") {
modules = [
"spring-kafka",
Expand Down