Adding kafka docker compose file
This commit is contained in:
54
docker-compose.yaml
Normal file
54
docker-compose.yaml
Normal file
@@ -0,0 +1,54 @@
|
||||
services:
|
||||
zookeeper:
|
||||
image: confluentinc/cp-zookeeper:latest
|
||||
environment:
|
||||
ZOOKEEPER_CLIENT_PORT: 2181
|
||||
ZOOKEEPER_TICK_TIME: 2000
|
||||
ports:
|
||||
- 22181:2181
|
||||
|
||||
kafka:
|
||||
image: confluentinc/cp-kafka:latest
|
||||
depends_on:
|
||||
- zookeeper
|
||||
ports:
|
||||
- 29092:29092
|
||||
environment:
|
||||
KAFKA_BROKER_ID: 1
|
||||
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
|
||||
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:29092
|
||||
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
|
||||
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
|
||||
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
|
||||
|
||||
# kafka UI tools
|
||||
kafka-ui:
|
||||
image: obsidiandynamics/kafdrop
|
||||
depends_on:
|
||||
- kafka
|
||||
ports:
|
||||
- 9091:9000
|
||||
environment:
|
||||
SERVER_SERVLET_CONTEXTPATH: "/"
|
||||
JVM_OPTS: "-Xms32M -Xmx64M"
|
||||
KAFKA_BROKERCONNECT: kafka:9092
|
||||
|
||||
#https://github.com/redpanda-data/console
|
||||
redpanda:
|
||||
image: docker.redpanda.com/vectorized/console:latest
|
||||
depends_on:
|
||||
- kafka
|
||||
ports:
|
||||
- "8080:8080"
|
||||
environment:
|
||||
KAFKA_BROKERS: kafka:9092
|
||||
|
||||
#https://github.com/consdata/kouncil
|
||||
kouncil:
|
||||
image: consdata/kouncil:latest
|
||||
depends_on:
|
||||
- kafka
|
||||
ports:
|
||||
- 9090:8080
|
||||
environment:
|
||||
bootstrapServers: kafka:9092
|
||||
54
kafka-command.md
Normal file
54
kafka-command.md
Normal file
@@ -0,0 +1,54 @@
|
||||
# Spring Boot Kafka Communication
|
||||
|
||||
##Commands
|
||||
|
||||
- Start Zookeeper
|
||||
```shell
|
||||
bin/zookeeper-server-start.sh config/zookeeper.properties
|
||||
```
|
||||
- Start Kafka
|
||||
```shell
|
||||
|
||||
```
|
||||
- Create Kafka topic
|
||||
```shell
|
||||
bin/kafka-topics.sh --create \
|
||||
--topic first-topic \
|
||||
--partitions=4 \
|
||||
--replication-factor=1 \
|
||||
--bootstrap-server localhost:9092
|
||||
```
|
||||
|
||||
- List Kafka Topics
|
||||
```shell
|
||||
bin/kafka-topics.sh --list --bootstrap-server localhost:9092
|
||||
```
|
||||
|
||||
- Console consumer
|
||||
```shell
|
||||
bin/kafka-console-consumer.sh \
|
||||
--bootstrap-server localhost:9092 \
|
||||
--property key.separator=: \
|
||||
--property print.key=true \
|
||||
--property print.offset=true \
|
||||
--property print.partition=true \
|
||||
--property print.value=true \
|
||||
--property print.headers=true \
|
||||
--topic first-topic \
|
||||
--from-beginning \
|
||||
--group group1
|
||||
```
|
||||
|
||||
- Console Consumer
|
||||
```shell
|
||||
bin/kafka-console-producer.sh \
|
||||
--bootstrap-server localhost:9092 \
|
||||
--property parse.key=true \
|
||||
--property key.separator=: \
|
||||
--topic first-topic
|
||||
```
|
||||
|
||||
- Payload
|
||||
```json
|
||||
mykey:"{\"name\": \"Jack\"}"
|
||||
```
|
||||
Reference in New Issue
Block a user