Kafka Producer/Consumer

Kafka basics: enough to understand the model, not yet enough to operate it in production.

Step 1: Run Kafka

Local Kafka is one compose file away. The bitnami image bundles Zookeeper or KRaft so you do not assemble a cluster by hand.

Step 2: Producer

Step 3: Consumer

from kafka import KafkaConsumer
consumer = KafkaConsumer("test", bootstrap_servers="localhost:9092")
for msg in consumer:
    print(msg.value)

Step 4: Topics and partitions

Topics and partitions are the only two concepts that matter at this stage. Get the partition model right and the rest of Kafka follows.

Antipatterns

What to do this week

Three moves. (1) Run the tutorial end-to-end on your own laptop / sandbox. (2) Apply the pattern to one production workload. (3) Document the variations you needed; share with the team.