Skip to main content

Posts

Showing posts from October, 2019

 Run first Kafka application -- Kafka inside (2)

start zookeeper: bin/zookeeper-server-start.sh config/zookeeper.properties start kafka server: bin/kafka-server-start.sh config/server.properties run the demo: a. For unlimited sync-producer-consumer run, `run bin/java-producer-consumer-demo.sh sync` b. For unlimited async-producer-consumer run, `run bin/java-producer-consumer-demo.sh`adf Let's take a look the source code java-producer-consumer-demo.sh,. the script is mainly use  kafka.examples.KafkaConsumerProducerDemo  as the demo class. the code created 2 topics(queues) for produce and consumer. the time to dig into code step by step. Firstly, take a look at source code of Producer Producer created messages and send to kafka server. on line 53, KafkaProducer send the message with callback :  ProducerRecord Per each message, the topic, messgeNo and messager body are defined. DemoCallBack provide asynchronous handling of request completion. here, DemoCallBack just print the message whe