From 69ff8ad389db01433ec621f8daf2a31b3e8c5294 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Tue, 22 Nov 2022 23:24:17 +0100 Subject: [PATCH] =?utf8?q?Verbesserungen=20&=20Korrekturen=20aus=20simple-?= =?utf8?q?consumer=20=C3=BCbernommen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- README.sh | 22 ++++----- docker-compose.yml | 45 +++++-------------- src/main/java/de/juplo/kafka/Application.java | 4 +- 3 files changed, 24 insertions(+), 47 deletions(-) diff --git a/README.sh b/README.sh index 879bae9..219a478 100755 --- a/README.sh +++ b/README.sh @@ -1,23 +1,22 @@ #!/bin/bash -IMAGE=juplo/supersimple-consumer:1.0-SNAPSHOT +IMAGE=juplo/simple-consumer:1.0-SNAPSHOT if [ "$1" = "cleanup" ] then - docker-compose down -v + docker-compose down -v --remove-orphans mvn clean exit fi -docker-compose rm -svf consumer docker-compose up -d kafka-1 kafka-2 kafka-3 cli +docker-compose rm -svf consumer if [[ $(docker image ls -q $IMAGE) == "" || "$1" = "build" ]] then - docker-compose rm -svf consumer mvn clean install || exit else echo "Using image existing images:" @@ -25,14 +24,15 @@ else fi docker-compose up setup -docker-compose up -d gateway requests-1 requests-2 consumer - -while ! [[ $(http 0:8080/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for gateway..."; sleep 1; done -while ! [[ $(http 0:8081/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for requests-1..."; sleep 1; done -while ! [[ $(http 0:8082/actuator/health 2> /dev/null) =~ "UP" ]]; do echo "Waiting for requests-2..."; sleep 1; done +docker-compose up -d producer +docker-compose ps -echo 6 | http -v :8080/peter +docker-compose up -d consumer +sleep 5 +docker-compose stop consumer -sleep 10 +docker-compose start consumer +sleep 5 +docker-compose stop producer consumer docker-compose logs consumer diff --git a/docker-compose.yml b/docker-compose.yml index 4118cc4..1d5d2fb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -89,56 +89,33 @@ services: image: juplo/toolbox command: > bash -c " - kafka-topics --bootstrap-server kafka:9092 --create --if-not-exists --topic in --partitions 2 --replication-factor 3 --config min.insync.replicas=2 - kafka-topics --bootstrap-server kafka:9092 --create --if-not-exists --topic out --partitions 2 --replication-factor 3 --config min.insync.replicas=2 - kafka-topics --bootstrap-server kafka:9092 --describe --topic in - kafka-topics --bootstrap-server kafka:9092 --describe --topic out + kafka-topics --bootstrap-server kafka:9092 --delete --if-exists --topic test + kafka-topics --bootstrap-server kafka:9092 --create --topic test --partitions 2 --replication-factor 3 --config min.insync.replicas=2 + kafka-topics --bootstrap-server kafka:9092 --describe --topic test " depends_on: - kafka-1 - kafka-2 - kafka-3 - cli: image: juplo/toolbox command: sleep infinity + depends_on: + - kafka-1 + - kafka-2 + - kafka-3 - gateway: - image: juplo/sumup-gateway--springified:1.0-SNAPSHOT - ports: - - 8080:8080 - environment: - server.port: 8080 - spring.kafka.bootstrap-servers: kafka:9092 - spring.kafka.client-id: gateway - sumup.gateway.topic: in - - requests-1: - image: juplo/sumup-requests-json:1.0-SNAPSHOT - ports: - - 8081:8080 - environment: - server.port: 8080 - sumup.requests.bootstrap-server: kafka:9092 - sumup.requests.client-id: requests-1 - - requests-2: - image: juplo/sumup-requests-json:1.0-SNAPSHOT - ports: - - 8082:8080 - environment: - server.port: 8080 - sumup.requests.bootstrap-server: kafka:9092 - sumup.requests.client-id: requests-2 + producer: + image: juplo/simple-producer:1.0-SNAPSHOT + command: kafka:9092 test producer consumer: image: juplo/supersimple-consumer:1.0-SNAPSHOT ports: - - 8090:8080 + - 8080:8080 environment: server.port: 8080 spring.kafka.bootstrap-servers: kafka:9092 - spring.kafka.producer.bootstrap-servers: kafka:9092 spring.kafak.client-id: consumer logging.level.org.apache.kafka.clients.consumer: INFO diff --git a/src/main/java/de/juplo/kafka/Application.java b/src/main/java/de/juplo/kafka/Application.java index a72431e..e3219c1 100644 --- a/src/main/java/de/juplo/kafka/Application.java +++ b/src/main/java/de/juplo/kafka/Application.java @@ -10,7 +10,7 @@ import org.springframework.kafka.annotation.KafkaListener; @Slf4j public class Application { - @KafkaListener(id = "supersimple", topics = "out") + @KafkaListener(id = "supersimple", topics = "test") public void recieve(String message) { log.info("Recieved message: {}", message); @@ -21,4 +21,4 @@ public class Application SpringApplication.run(Application.class, args); } } -// end::supersimple[] \ No newline at end of file +// end::supersimple[] -- 2.20.1