You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spring-kafka-docs/src/main/antora/modules/ROOT/pages/testing.adoc
+18-3Lines changed: 18 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,16 @@
3
3
4
4
The `spring-kafka-test` jar contains some useful utilities to assist with testing your applications.
5
5
6
+
[[ekb]]
7
+
== EmbeddedKafkaBroker
8
+
9
+
Two implementations are provided:
10
+
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)
13
+
14
+
There are several techniques to configure the broker as discussed in the following sections.
15
+
6
16
[[ktu]]
7
17
== KafkaTestUtils
8
18
@@ -47,7 +57,7 @@ If this is not possible for some reason, note that the `consumeFromEmbeddedTopic
47
57
Since it does not have access to the consumer properties, you must use the overloaded method that takes a `seekToEnd` boolean parameter to seek to the end instead of the beginning.
48
58
====
49
59
50
-
A JUnit 4 `@Rule` wrapper for the `EmbeddedKafkaBroker` is provided to create an embedded Kafka and an embedded Zookeeper server.
60
+
A JUnit 4 `@Rule` wrapper for the `EmbeddedKafkaZKBroker` is provided to create an embedded Kafka and an embedded Zookeeper server.
51
61
(See xref:testing.adoc#embedded-kafka-annotation[@EmbeddedKafka Annotation] for information about using `@EmbeddedKafka` with JUnit 5).
52
62
The following listing shows the signatures of those methods:
@@ -216,7 +228,8 @@ In addition, these properties can be provided:
216
228
- `spring.kafka.embedded.ports` - ports (comma-separated value) for every Kafka broker to start, `0` if random port is a preferred; the number of values must be equal to the `count` mentioned above;
217
229
- `spring.kafka.embedded.topics` - topics (comma-separated value) to create in the started Kafka cluster;
218
230
- `spring.kafka.embedded.partitions` - number of partitions to provision for the created topics;
219
-
- `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.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;
232
+
- `spring.kafka.embedded.kraft` - when false, use an `EmbeddedKafkaZKBroker` instead of an `EmbeddedKafkaKraftBroker`.
220
233
221
234
Essentially these properties mimic some of the `@EmbeddedKafka` attributes.
222
235
@@ -283,6 +296,8 @@ public class KafkaStreamsTests {
283
296
284
297
Starting with version 2.2.4, you can also use the `@EmbeddedKafka` annotation to specify the Kafka ports property.
285
298
299
+
Starting with version 3.1; set the `kraft` property to `false` to use an `EmbeddedKafkaZKBroker` instead of an `EmbeddedKafkaKraftBroker`.
300
+
286
301
The following example sets the `topics`, `brokerProperties`, and `brokerPropertiesLocation` attributes of `@EmbeddedKafka` support property placeholder resolutions:
0 commit comments