Build an order pipeline
Proof project · Article 12 of 12 · 4 min read
This project uses most of the trail at once and gives you something worth showing in an interview.
The short version
Build a small pipeline. A producer sends orders keyed by customer, a processor turns them into kitchen tickets, and a group of two workers handles the tickets.
Details
Build it in this order, and check each part works before you add the next.
- Create
ordersandticketswith 3 partitions each. - Write a producer that sends 20 orders for 4 customers, with the customer as the key and
acksset toall. - Write a processor that reads
orders, writes one ticket for each order and commits after each write. - Run two workers in the group
kitchenthat readtickets, print each ticket and commit after printing. - Stop one worker halfway through, then start it again.
Try it yourself
You are done when all of these are true:
- Every order is printed as a ticket, and none are lost when a worker stops.
- Tickets for one customer print in the order they were sent.
- Describing the
kitchengroup shows a lag of 0 on every partition. - A short README explains why you chose your key and when you commit.
Explain it to the duck
Walk through what happens to one order if the processor crashes right after writing the ticket but before committing.
Tested with: Kafka 4.1.0 in Docker, Python 3.12 and confluent-kafka 2.11.
Where to go next
- Kafka Connect(opens in a new tab) Move data between Kafka and databases without writing a consumer.
- Kafka Streams(opens in a new tab) Joins, windows and exactly once processing, handled for you in Java.
- Message schemas Agree on message formats across teams with Avro or Protobuf and a schema registry.