server config
broker.id=0
listeners=PLAINTEXT://192.168.116.128:9092
log.dirs=/tmp/kafka-logs
zokeeper start
$ bin/zookeeper-server-start.sh config/zookeeper.properties
kafka start
$ bin/kafka-server-start.sh config/server.properties
Create topic
[app@localhost kafka_2.12-2.0.0]$ ./bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor=1 --partitions 1 --topic test
Created topic "test".
Check topic list
[app@localhost kafka_2.12-2.0.0]$ ./bin/kafka-topics.sh --list --zookeeper localhost:2181
__consumer_offsets
test
Remove topic
app@ubuntu:~/kafka/kafka_2.12-2.0.0$ ./bin/kafka-topics.sh --zookeeper 127.0.0.1:2181 --delete --topic request-topic
Start a consumer
[app@localhost kafka_2.12-2.0.0]$ ./bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test
Send some message
[app@localhost kafka_2.12-2.0.0]$ ./bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
>this is a message
>this is another message
Generate config file
[app@localhost kafka_2.12-2.0.0]$ cp config/server.properties config/server-1.propperties
[app@localhost kafka_2.12-2.0.0]$ cp config/server.properties config/server-2.propperties
Change properties
[app@localhost kafka_2.12-2.0.0]$ vi config/server-1.propperties
broker.id=1
listeners=PLAINTEXT://:9093
log.dirs=/tmp/kafka-logs-1
[app@localhost kafka_2.12-2.0.0]$ vi config/server-2.propperties
broker.id=2
listeners=PLAINTEXT://:9094
log.dirs=/tmp/kafka-logs-2
; Produce, Consume
application.properties
spring.profiles.active=basic
basic.kafka.bootstrap-servers=192.168.116.128:9092
; Generate request and reply response
application.properties
spring.profiles.active=rpc
## for rpc
# https://dzone.com/articles/synchronous-kafka-using-spring-request-reply-1
rpc.kafka.bootstrap-servers=192.168.116.128:9092
rpc.kafka.topic.request-topic=request-topic
rpc.kafka.topic.requestreply-topic=requestreply-topic
rpc.kafka.consumergroup=requestreplygorup