Skip to content

Commit 35d26e1

Browse files
authored
GH-3238: EmbeddedKafaka#kraft default to false
Fixes: #3238 Switch `EmbeddedKafaka#kraft` default to `false`.
1 parent 4a5a849 commit 35d26e1

File tree

5 files changed

+13
-12
lines changed

5 files changed

+13
-12
lines changed

spring-kafka-docs/src/main/antora/modules/ROOT/pages/testing.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ The `spring-kafka-test` jar contains some useful utilities to assist with testin
88

99
Two implementations are provided:
1010

11-
* `EmbeddedKafkaZKBroker` - legacy implementation which starts an embedded `Zookeeper` instance.
12-
* `EmbeddedKafkaKraftBroker` - (default) uses `Kraft` instead of `Zookeeper` in combined controller and broker modes (since 3.1).
11+
* `EmbeddedKafkaZKBroker` - legacy implementation which starts an embedded `Zookeeper` instance (which is still the default when using `EmbeddedKafka`).
12+
* `EmbeddedKafkaKraftBroker` - uses `Kraft` instead of `Zookeeper` in combined controller and broker modes (since 3.1).
1313

1414
There are several techniques to configure the broker as discussed in the following sections.
1515

@@ -228,7 +228,7 @@ In addition, these properties can be provided:
228228
- `spring.kafka.embedded.topics` - topics (comma-separated value) to create in the started Kafka cluster;
229229
- `spring.kafka.embedded.partitions` - number of partitions to provision for the created topics;
230230
- `spring.kafka.embedded.broker.properties.location` - the location of the file for additional Kafka broker configuration properties; the value of this property must follow the Spring resource abstraction pattern;
231-
- `spring.kafka.embedded.kraft` - when false, use an `EmbeddedKafkaZKBroker` instead of an `EmbeddedKafkaKraftBroker`.
231+
- `spring.kafka.embedded.kraft` - default false, when true, use an `EmbeddedKafkaKraftBroker` instead of an `EmbeddedKafkaZKBroker`.
232232

233233
Essentially these properties mimic some of the `@EmbeddedKafka` attributes.
234234

@@ -295,7 +295,7 @@ public class KafkaStreamsTests {
295295

296296
Starting with version 2.2.4, you can also use the `@EmbeddedKafka` annotation to specify the Kafka ports property.
297297

298-
Starting with version 3.1, set the `kraft` property to `false` to use an `EmbeddedKafkaZKBroker` instead of an `EmbeddedKafkaKraftBroker`.
298+
Starting with version 3.2, set the `kraft` property to `true` to use an `EmbeddedKafkaKraftBroker` instead of an `EmbeddedKafkaZKBroker`.
299299

300300
The following example sets the `topics`, `brokerProperties`, and `brokerPropertiesLocation` attributes of `@EmbeddedKafka` support property placeholder resolutions:
301301

spring-kafka-test/src/main/java/org/springframework/kafka/test/context/EmbeddedKafka.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2023 the original author or authors.
2+
* Copyright 2017-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -67,6 +67,7 @@
6767
* @author Sergio Lourenco
6868
* @author Pawel Lozinski
6969
* @author Adrian Chlebosz
70+
* @author Soby Chacko
7071
*
7172
* @since 1.3
7273
*
@@ -193,11 +194,11 @@
193194
int adminTimeout() default EmbeddedKafkaBroker.DEFAULT_ADMIN_TIMEOUT;
194195

195196
/**
196-
* Use KRaft instead of Zookeeper; default true.
197+
* Use KRaft instead of Zookeeper; default false.
197198
* @return whether to use KRaft.
198199
* @since 3.6
199200
*/
200-
boolean kraft() default true;
201+
boolean kraft() default false;
201202

202203
}
203204

spring-kafka/src/test/java/org/springframework/kafka/annotation/EnableKafkaIntegrationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@
195195
"annotated29", "annotated30", "annotated30reply", "annotated31", "annotated32", "annotated33",
196196
"annotated34", "annotated35", "annotated36", "annotated37", "foo", "manualStart", "seekOnIdle",
197197
"annotated38", "annotated38reply", "annotated39", "annotated40", "annotated41", "annotated42",
198-
"annotated43", "annotated43reply", "seekToComputeFn"})
198+
"annotated43", "annotated43reply", "seekToComputeFn"}, kraft = true)
199199
@TestPropertySource(properties = "spel.props=fetch.min.bytes=420000,max.poll.records=10")
200200
public class EnableKafkaIntegrationTests {
201201

spring-kafka/src/test/java/org/springframework/kafka/streams/KafkaStreamsInteractiveQueryServiceTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
import org.springframework.kafka.core.ProducerFactory;
6868
import org.springframework.kafka.listener.ConcurrentMessageListenerContainer;
6969
import org.springframework.kafka.test.EmbeddedKafkaBroker;
70-
import org.springframework.kafka.test.EmbeddedKafkaKraftBroker;
70+
import org.springframework.kafka.test.EmbeddedKafkaZKBroker;
7171
import org.springframework.kafka.test.context.EmbeddedKafka;
7272
import org.springframework.kafka.test.utils.KafkaTestUtils;
7373
import org.springframework.retry.RetryPolicy;
@@ -96,7 +96,7 @@ class KafkaStreamsInteractiveQueryServiceTests {
9696
public static final String NON_EXISTENT_STORE = "my-non-existent-store";
9797

9898
@Autowired
99-
private EmbeddedKafkaKraftBroker embeddedKafka;
99+
private EmbeddedKafkaZKBroker embeddedKafka;
100100

101101
@Autowired
102102
private StreamsBuilderFactoryBean streamsBuilderFactoryBean;

spring-kafka/src/test/java/org/springframework/kafka/streams/KafkaStreamsTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2023 the original author or authors.
2+
* Copyright 2017-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -97,7 +97,7 @@
9797
brokerProperties = {
9898
"auto.create.topics.enable=${topics.autoCreate:false}",
9999
"delete.topic.enable=${topic.delete:true}" },
100-
brokerPropertiesLocation = "classpath:/${broker.filename:broker}.properties")
100+
brokerPropertiesLocation = "classpath:/${broker.filename:broker}.properties", kraft = true)
101101
public class KafkaStreamsTests {
102102

103103
static final String STREAMING_TOPIC1 = "streamingTopic1";

0 commit comments

Comments
 (0)