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/asciidoc/testing.adoc
+8-1Lines changed: 8 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,11 +37,18 @@ public static Map<String, Object> producerProps(EmbeddedKafkaBroker embeddedKafk
37
37
----
38
38
====
39
39
40
-
NOTE: Starting with version 2.5, the `consumerProps` method sets the `ConsumerConfig.AUTO_OFFSET_RESET_CONFIG` to `earliest`.
40
+
[NOTE]
41
+
====
42
+
Starting with version 2.5, the `consumerProps` method sets the `ConsumerConfig.AUTO_OFFSET_RESET_CONFIG` to `earliest`.
41
43
This is because, in most cases, you want the consumer to consume any messages sent in a test case.
42
44
The `ConsumerConfig` default is `latest` which means that messages already sent by a test, before the consumer starts, will not receive those records.
43
45
To revert to the previous behavior, set the property to `latest` after calling the method.
44
46
47
+
When using the embedded broker, it is generally best practice to use a different topic for each test, to prevent cross-talk.
48
+
If this is not possible for some reason, note that the `consumeFromEmbeddedTopics` method's default behavior is to seek the assigned partitions to the beginning after assignment.
49
+
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.
50
+
====
51
+
45
52
A JUnit 4 `@Rule` wrapper for the `EmbeddedKafkaBroker` is provided to create an embedded Kafka and an embedded Zookeeper server.
46
53
(See <<embedded-kafka-annotation>> for information about using `@EmbeddedKafka` with JUnit 5).
47
54
The following listing shows the signatures of those methods:
0 commit comments