An open API service indexing awesome lists of open source software.

https://github.com/haarismemon/conduktortask


https://github.com/haarismemon/conduktortask

Last synced: about 1 month ago
JSON representation

Awesome Lists containing this project

README

        

# Conduktor Task

The chosen topic name for this project is `people-records`.

## Setup

First run the kafka docker container:
```
docker run -p 9092:9092 apache/kafka:3.7.0
```

To get container id for after running the above:
```
docker ps
```

Then create the three partitions for the `people-records` topic:
```
docker exec -it /opt/kafka/bin/kafka-topics.sh \
--bootstrap-server localhost:9092 \
--create \
--topic people-records \
--partitions 3 \
--replication-factor 1 \
--config cleanup.policy=delete
```

Then run the kafka producer, by selecting `ProducerService` when running `sbt run`.

This will load the people records from the json file into the `people-records` topic.

Finally, to obtain the people records with the kafka consumer, run the REST API server by selecting `ConsumerApiServer` when running `sbt run`.

The endpoint to hit to obtain the people records is:
```
localhost:8080/topic/people-records/{offset-value}?count={count-value}
```

## Useful Debugging Commands

To check for existing topics in the kafka container:
```
docker exec -it /opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --list
```

To confirm the topic has been configured correctly with the correct number of partitions:
```
docker exec -it /opt/kafka/bin/kafka-topics.sh \
--bootstrap-server localhost:9092 \
--describe \
--topic people-records
```

To check how many messages in each partition for the topic:
```
docker exec -it /opt/kafka/bin/kafka-log-dirs.sh \
--bootstrap-server localhost:9092 \
--describe
```

To read messages from the topic as they come in:
```
docker exec -it /opt/kafka/bin/kafka-console-consumer.sh \
--bootstrap-server localhost:9092 \
--topic people-records
```
Add `--from-beginning` flag to see all messages.