Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run-kafka:
@docker exec -it fc2-kafka-kafka-1 bash
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Kafka basics and commands
Prerequisite: make sure the Kafka broker is running and reachable at localhost:9092.

## How to read the diagram (kafka.png)
![Kafka overview](./kafka.png)

## Delivery
![Kafka delivery overview](./delivery.png)
# Commands

## Topics
- Create a topic (3 partitions):
```shell
kafka-topics --create --topic test --bootstrap-server localhost:9092 --partitions 3
```
- List all topics:
```shell
kafka-topics --list --bootstrap-server localhost:9092
```
- Describe a topic (partitions/replicas/leader):
```shell
kafka-topics --describe --topic test --bootstrap-server localhost:9092
```
- Delete a topic:
```shell
kafka-topics --delete --topic test --bootstrap-server localhost:9092
```

## Console Producer
- Write messages from stdin to a topic. Each line you type is a message:
```shell
kafka-console-producer --topic test --bootstrap-server localhost:9092
```

## Console Consumer
- Read new messages from the tip of the log:
```shell
kafka-console-consumer --topic test --bootstrap-server localhost:9092
```
- Read everything from the beginning of the topic:
```shell
kafka-console-consumer --topic test --bootstrap-server localhost:9092 --from-beginning
```
- Join a consumer group (enables scaling and offset tracking):
```shell
kafka-console-consumer --topic test --bootstrap-server localhost:9092 --group group-x
```

## Consumer Groups
- Describe a group (lags, offsets, assignments). Start at least one consumer in the group first:
```shell
kafka-consumer-groups --bootstrap-server localhost:9092 --group group-x --describe
```
Binary file added delivery.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 1 addition & 4 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
version: "3"

services:

services:
zookeeper:
image: confluentinc/cp-zookeeper:latest
environment:
Expand Down
Binary file added kafka.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.