Skip to content
This repository has been archived by the owner on Feb 21, 2024. It is now read-only.

Commit

Permalink
Add notes: Kafka: The definitive guide
Browse files Browse the repository at this point in the history
- Chapter 1: produce and consume messages by using sample kafka scripts
  • Loading branch information
lealceldeiro committed Dec 2, 2023
1 parent 22f7678 commit 49a1f58
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions KafkaTheDefinitiveGuide/Chapter2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ docker network create app-tier --driver bridge
> network.
```shell
docker run -d --name kafka-server --hostname kafka-server \
--network app-tier \
docker run -d --name kafka-server --hostname kafka-server --network app-tier \
-e KAFKA_CFG_NODE_ID=0 \
-e KAFKA_CFG_PROCESS_ROLES=controller,broker \
-e KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093 \
Expand All @@ -53,13 +52,34 @@ docker run -it --rm --network app-tier bitnami/kafka:latest kafka-topics.sh --bo
--create --replication-factor 1 --partitions 1 --topic topic1
```

4. Verify the previously created topic
5. Verify the previously created topic

```shell
docker run -it --rm --network app-tier bitnami/kafka:latest kafka-topics.sh --bootstrap-server kafka-server:9092 \
--describe --topic test_topic
--describe --topic topic1
```

6. Produce messages to the previously created topic

```shell
docker run -it --rm --network app-tier \
bitnami/kafka:latest kafka-console-producer.sh --bootstrap-server kafka-server:9092 --topic topic1
```

> When the console waits for input (symbol `>` visible) enter some message and hit enter (once for every message).
> To finish producing messages do `Ctrl` + `C` (`^C`)
6. Consume messages from the previously created topic

```shell
docker run -it --rm --network app-tier \
bitnami/kafka:latest kafka-console-consumer.sh --bootstrap-server kafka-server:9092 \
--topic topic1 --from-beginning
```

> When the console waits for input (symbol `>` visible) enter some message and hit enter (once for every message).
> To finish producing messages do `Ctrl` + `C` (`^C`)
<details>
<summary>Docker run info</summary>
See https://docs.docker.com/engine/reference/commandline/run/ for more details.
Expand Down

0 comments on commit 49a1f58

Please sign in to comment.