From 81b264a27d2e7daface2ff58b710703c4ee21bca Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sat, 30 Jan 2021 14:43:04 +0100 Subject: [PATCH] Improved example execution in README.sh * The setup for Docker Compose uses a specific version of Kafka * README.sh uses Docker to execute kafka-commands * No error-message is issued, if the topic already exists --- README.sh | 8 ++++---- docker-compose.yml | 11 +++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/README.sh b/README.sh index 6a4ef4c..2557d2f 100755 --- a/README.sh +++ b/README.sh @@ -26,16 +26,16 @@ trap 'kill $(jobs -p)' EXIT docker-compose up -d zookeeper kafka -while ! [[ $(zookeeper-shell zookeeper:2181 ls /brokers/ids 2> /dev/null) =~ 1001 ]]; +while ! [[ $(docker-compose exec kafka zookeeper-shell zookeeper:2181 ls /brokers/ids 2> /dev/null) =~ 1001 ]]; do echo "Waiting for kafka..."; sleep 1; done -kafka-topics --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 3 --topic outbox +docker-compose exec kafka kafka-topics --zookeeper zookeeper:2181 --create --if-not-exists --replication-factor 1 --partitions 3 --topic outbox -docker-compose up -d jdbc outbox +docker-compose up -d jdbc outbox kafkacat while ! [[ $(http :8080/actuator/health 2>/dev/null | jq -r .status) == "UP" ]]; do @@ -44,7 +44,7 @@ do done -kafkacat -C -b localhost:9092 -t outbox & +docker-compose logs -f kafkacat & echo peter | http :8080/users echo franz | http :8080/users diff --git a/docker-compose.yml b/docker-compose.yml index 2cd2608..23c39f1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,14 +3,14 @@ version: "3" services: zookeeper: - image: "confluentinc/cp-zookeeper:latest" + image: confluentinc/cp-zookeeper:6.0.1 ports: - 2181:2181 environment: ZOOKEEPER_CLIENT_PORT: 2181 kafka: - image: confluentinc/cp-kafka:latest + image: confluentinc/cp-kafka:6.0.1 ports: - 9092:9092 environment: @@ -22,6 +22,13 @@ services: depends_on: - zookeeper + kafkacat: + image: confluentinc/cp-kafkacat:6.0.1 + command: "kafkacat -C -b kafka:9093 -t outbox -K:" + tty: true + depends_on: + - kafka + jdbc: image: juplo/jdbc:outbox ports: -- 2.20.1