Create Topic, Producer & Consumer in Kafka

Create a Kafka Topic for the inventory purchase data

kafka-topics --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic inventory_purchases
  • For Mac Test (partition 1 and replication-factor 1)
kafka-topics --create --bootstrap-server localhost:9092 --replication-factor 3 --partitions 6 --topic inventory_purchases

Start a command line producer

Kafka console producer

kafka-console-producer --broker-list localhost:9092 --topic inventory_purchases
>product: apples, quantity: 5
>product: lemons, quantity: 7

Kafka console consumer

kafka-console-consumer --bootstrap-server localhost:9092 --topic inventory_purchases --from-beginning
product: lemons, quantity: 7
product: apples, quantity: 5

Leave a Reply

Your email address will not be published.

ANOTE.DEV