Thursday, October 17, 2019

Kafka cheat sheet

View topic list : both methods work.

D:\apps\kafka_2.12-2.3.0>.\bin\windows\kafka-topics.bat --zookeeper localhost:2181 --list
__consumer_offsets
rss
test-1


D:\apps\kafka_2.12-2.3.0>.\bin\windows\kafka-topics.bat --bootstrap-server localhost:9092 --list
__consumer_offsets
rss
test-1


View a topic
 D:\apps\kafka_2.12-2.3.0>.\bin\windows\kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic rss --from-beginning
{
  "source": "NY Times",
  "title": "Warren Draws Fire From All Sides, Reflecting a Shift in Fortunes in Race",
  "url": "https://www.nytimes.com/2019/10/15/us/politics/october-democratic-debate-recap.html?emc\u003drss\u0026partner\u003drss",
  "description": "The criticism of Elizabeth Warren illustrated her status as an emerging front-runner, while Joe Biden faced scrutiny over his sonΓÇÖs financial dealings overseas.",
  "publishedAt": 1571215157000
}

... 

Create a topic
D:\apps\kafka_2.12-2.3.0>.\bin\windows\kafka-topics.bat --zookeeper localhost:2181 --create --topic test-1 --partitions 1 --replication-factor 1
Created topic test-1.


Produce topic message
D:\apps\kafka_2.12-2.3.0>.\bin\windows\kafka-console-producer --topic test-1 --broker-list localhost:9092
>hello world
>hello world2

>


No comments: