From 83d608700fa542088c1eb0575e79270a24b96f59 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Tue, 12 Nov 2024 03:39:10 +0100 Subject: [PATCH] =?utf8?q?Setup=20&=20Projekt-Konfiguration=20aus=20`produ?= =?utf8?q?cer/spring-producer`=20=C3=BCbernommen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 +- README.sh | 27 ++++++++++++++-------- docker/docker-compose.yml | 48 ++++++++++++++------------------------- pom.xml | 13 ++++++----- 4 files changed, 43 insertions(+), 47 deletions(-) diff --git a/Dockerfile b/Dockerfile index ae52522..9e196ff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM openjdk:17-jdk-slim +FROM eclipse-temurin:21-jre VOLUME /tmp COPY target/*.jar /opt/app.jar ENTRYPOINT [ "java", "-jar", "/opt/app.jar" ] diff --git a/README.sh b/README.sh index 867070b..929b422 100755 --- a/README.sh +++ b/README.sh @@ -4,12 +4,13 @@ IMAGE=juplo/supersimple-producer:1.0-SNAPSHOT if [ "$1" = "cleanup" ] then - docker-compose -f docker/docker-compose.yml down -t0 -v --remove-orphans + docker compose -f docker/docker-compose.yml down -t0 -v --remove-orphans mvn clean exit fi -docker-compose -f docker/docker-compose.yml up -d --remove-orphans kafka-1 kafka-2 kafka-3 +docker compose -f docker/docker-compose.yml up -d --remove-orphans kafka-1 kafka-2 kafka-3 +docker compose -f docker/docker-compose.yml rm -svf producer if [[ $(docker image ls -q $IMAGE) == "" || @@ -22,12 +23,20 @@ else docker image ls $IMAGE fi -docker-compose -f docker/docker-compose.yml up --remove-orphans setup || exit 1 +docker compose -f docker/docker-compose.yml up --remove-orphans setup || exit 1 -docker-compose -f docker/docker-compose.yml up -t0 -d cli -docker-compose -f docker/docker-compose.yml ps -docker-compose -f docker/docker-compose.yml up producer -# tag::kafkacat[] -kafkacat -b :9092 -t test -e -f'topic=%t\tpartition=%p\toffset=%o\tkey=%k\tvalue=%s\n' -# end::kafkacat[] +docker compose -f docker/docker-compose.yml up -d producer +docker compose -f docker/docker-compose.yml up -d consumer-1 consumer-2 +sleep 15 + +docker compose -f docker/docker-compose.yml stop producer + +echo +echo "Von consumer-1 empfangen:" +docker compose -f docker/docker-compose.yml logs consumer-1 | grep '\ test\/.' +echo +echo "Von consumer-2 empfangen:" +docker compose -f docker/docker-compose.yml logs consumer-2 | grep '\ test\/.' + +docker compose -f docker/docker-compose.yml stop consumer-1 consumer-2 diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index ca8befa..3591900 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,7 +1,6 @@ -version: '3.2' services: zookeeper: - image: confluentinc/cp-zookeeper:7.5.1 + image: confluentinc/cp-zookeeper:7.7.1 environment: ZOOKEEPER_CLIENT_PORT: 2181 ports: @@ -11,7 +10,7 @@ services: - zookeeper-log:/var/lib/zookeeper/log kafka-1: - image: confluentinc/cp-kafka:7.5.1 + image: confluentinc/cp-kafka:7.7.1 environment: KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 KAFKA_LISTENERS: BROKER://:9092, LOCALHOST://:9081 @@ -21,15 +20,8 @@ services: KAFKA_INTER_BROKER_LISTENER_NAME: BROKER KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 3 KAFKA_AUTO_CREATE_TOPICS_ENABLE: "false" - KAFKA_AUTHORIZER_CLASS_NAME: kafka.security.authorizer.AclAuthorizer - KAFKA_ALLOW_EVERYONE_IF_NO_ACL_FOUND: "true" - KAFKA_OPTS: - -javaagent:/usr/share/java/cp-base-new/jmx_prometheus_javaagent-0.18.0.jar=0.0.0.0:80:/etc/jmx-exporter.yml - -Dcom.sun.management.jmxremote=true - -Dcom.sun.management.jmxremote.port=9101 - -Dcom.sun.management.jmxremote.authenticate=false + KAFKA_LOG_RETENTION_CHECK_INTERVAL_MS: 1000 volumes: - - ./jmx-exporter.yml:/etc/jmx-exporter.yml:ro - kafka-1-data:/var/lib/kafka/data ports: - 9081:9081 @@ -38,7 +30,7 @@ services: - zookeeper kafka-2: - image: confluentinc/cp-kafka:7.5.1 + image: confluentinc/cp-kafka:7.7.1 environment: KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 KAFKA_LISTENERS: BROKER://:9092, LOCALHOST://:9082 @@ -48,15 +40,8 @@ services: KAFKA_INTER_BROKER_LISTENER_NAME: BROKER KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 3 KAFKA_AUTO_CREATE_TOPICS_ENABLE: "false" - KAFKA_AUTHORIZER_CLASS_NAME: kafka.security.authorizer.AclAuthorizer - KAFKA_ALLOW_EVERYONE_IF_NO_ACL_FOUND: "true" - KAFKA_OPTS: - -javaagent:/usr/share/java/cp-base-new/jmx_prometheus_javaagent-0.18.0.jar=0.0.0.0:80:/etc/jmx-exporter.yml - -Dcom.sun.management.jmxremote=true - -Dcom.sun.management.jmxremote.port=9101 - -Dcom.sun.management.jmxremote.authenticate=false + KAFKA_LOG_RETENTION_CHECK_INTERVAL_MS: 10000 volumes: - - ./jmx-exporter.yml:/etc/jmx-exporter.yml:ro - kafka-2-data:/var/lib/kafka/data ports: - 9092:9082 @@ -70,7 +55,7 @@ services: - zookeeper kafka-3: - image: confluentinc/cp-kafka:7.5.1 + image: confluentinc/cp-kafka:7.7.1 environment: KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 KAFKA_LISTENERS: BROKER://:9092, LOCALHOST://:9083 @@ -80,15 +65,8 @@ services: KAFKA_INTER_BROKER_LISTENER_NAME: BROKER KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 3 KAFKA_AUTO_CREATE_TOPICS_ENABLE: "false" - KAFKA_AUTHORIZER_CLASS_NAME: kafka.security.authorizer.AclAuthorizer - KAFKA_ALLOW_EVERYONE_IF_NO_ACL_FOUND: "true" - KAFKA_OPTS: - -javaagent:/usr/share/java/cp-base-new/jmx_prometheus_javaagent-0.18.0.jar=0.0.0.0:80:/etc/jmx-exporter.yml - -Dcom.sun.management.jmxremote=true - -Dcom.sun.management.jmxremote.port=9101 - -Dcom.sun.management.jmxremote.authenticate=false + KAFKA_LOG_RETENTION_CHECK_INTERVAL_MS: 10000 volumes: - - ./jmx-exporter.yml:/etc/jmx-exporter.yml:ro - kafka-3-data:/var/lib/kafka/data ports: - 9083:9083 @@ -97,7 +75,7 @@ services: - zookeeper schema-registry: - image: confluentinc/cp-schema-registry:7.5.1 + image: confluentinc/cp-schema-registry:7.7.1 environment: SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS: kafka-1:9092,kafka-2:9092,kafka-3:9092 SCHEMA_REGISTRY_HOST_NAME: schema-registry @@ -111,7 +89,7 @@ services: - kafka-3 connect: - image: confluentinc/cp-kafka-connect:7.5.1 + image: confluentinc/cp-kafka-connect:7.7.1 environment: CONNECT_BOOTSTRAP_SERVERS: kafka-1:9092,kafka-2:9092,kafka-3:9092 CONNECT_REST_PORT: 8083 @@ -218,6 +196,14 @@ services: spring.kafka.client-id: producer spring.kafka.template.default-topic: test + consumer-1: + image: juplo/simple-consumer:1.0-SNAPSHOT + command: kafka:9092 test my-group consumer-1 + + consumer-2: + image: juplo/simple-consumer:1.0-SNAPSHOT + command: kafka:9092 test my-group consumer-2 + volumes: zookeeper-data: zookeeper-log: diff --git a/pom.xml b/pom.xml index ee60567..8f6258c 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ org.springframework.boot spring-boot-starter-parent - 2.7.2 + 3.3.4 @@ -18,7 +18,7 @@ 1.0-SNAPSHOT - 17 + 21 @@ -64,10 +64,14 @@ + + pl.project13.maven + git-commit-id-plugin + io.fabric8 docker-maven-plugin - 0.33.0 + 0.45.0 @@ -85,9 +89,6 @@ - - maven-failsafe-plugin - -- 2.20.1