Skip to content

Commit 851c3dd

Browse files
authored
fix: wording tweaks and typo fixes in testcontainers tutorial (#4) (#63)
1 parent 11a7aa5 commit 851c3dd

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

kafka-native-testcontainers/kafka/README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,32 @@
33

44
# How to integration test a Kafka application with a native (non-JVM) Kafka binary in Testcontainers
55

6-
In this tutorial we will use the `apache/kafka-native` Docker Image released in Apache Kafka® 3.8 to integration test a basic event routing Kafka consumer / producer application. This [GraalVM](https://www.graalvm.org/)-based image runs a [native binary](https://www.graalvm.org/latest/reference-manual/native-image/) Kafka broker running in KRaft [combined mode](https://kafka.apache.org/documentation/#kraft_role) by default (i.e., it serves as both broker and KRaft controller). As a native binary executable, it offers the following test scenario benefits compared to the JVM-based `apache/kafka` image:
6+
In this tutorial, we will use the `apache/kafka-native` Docker Image released in Apache Kafka® 3.8 to integration test a basic event routing Kafka consumer / producer application. This [GraalVM](https://www.graalvm.org/)-based image runs a [native binary](https://www.graalvm.org/latest/reference-manual/native-image/) Kafka broker running in KRaft [combined mode](https://kafka.apache.org/documentation/#kraft_role) by default (i.e., it serves as both broker and KRaft controller). As a native binary executable, it offers the following test scenario benefits compared to the JVM-based `apache/kafka` image:
77

88
1. Smaller image size (faster download time)
99
2. Faster startup time
1010
3. Lower memory usage
1111

1212
Given these benefits, this image is well-suited for non-production development and testing scenarios that require an actual Kafka broker. [Testcontainers](https://java.testcontainers.org/modules/kafka/) supports this image as of version `1.20.1` of `org.testcontainers`'s `kafka` artifact.
1313

14-
Testing in this way is as easy as declaring the [Testcontainers Kafka dependency](https://mvnrepository.com/artifact/org.testcontainers/kafka/1.20.1) in your dependency manager and then writing a test like so:
14+
Testing in this way is as easy as declaring the [Testcontainers Kafka dependency](https://mvnrepository.com/artifact/org.testcontainers/kafka/1.20.1) in your dependency manager and then writing a test like this:
1515

1616
```java
1717
try (KafkaContainer kafka = new KafkaContainer(DockerImageName.parse("apache/kafka-native:<VERSION>>"))) {
1818
kafka.start();
19-
19+
2020
// Instantiate and start your application with kafka.getBootstrapServers() as your bootstrap servers endpoint
21-
22-
// Generate inputs, e.g., if the application is a consumer, then create a Producer instantiated with
21+
22+
// Generate inputs. E.g., if the application is a consumer, then create a Producer instantiated with
2323
// properties that include:
2424
//
2525
// properties.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, kafka.getBootstrapServers());
26-
27-
// Collect outputs, e.g., if the application produces events, then create a Consumer instantiated with
28-
// properties than include:
26+
27+
// Collect outputs. E.g., if the application produces events, then create a Consumer instantiated with
28+
// properties that include:
2929
//
3030
// properties.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, kafka.getBootstrapServers());
31-
31+
3232
// Assert that collected outputs are as expected!
3333

3434
kafka.stop();
@@ -42,10 +42,10 @@ event routing application that routes input numbers to three potential output to
4242
composite numbers, and a third dead-letter queue where we will send any naughty events (e.g., if the event is not
4343
deserializable as an integer).
4444

45-
Note: this kind of simple routing logic would be better implemented in Kafka Streams by implementing a
45+
_*Note that this kind of simple routing logic would be better implemented in Kafka Streams by implementing a
4646
[`TopicNameExtractor`](https://javadoc.io/static/org.apache.kafka/kafka-streams/3.7.0/org/apache/kafka/streams/processor/TopicNameExtractor.html)
4747
that dynamically routes events as described above. We're just having some math fun with a basic consumer / producer application for
48-
testing demonstration purposes.
48+
testing demonstration purposes.*_
4949

5050
The anatomy of `KafkaPrimalityRouter` has a `main` method that mostly just does some argument parsing and then hands off
5151
to a function that does the event routing given injected `Producer` and `Consumer` instances. Specifically, `runConsume`

0 commit comments

Comments
 (0)