Anpassungen des Projekts/Setups aus 'simple-producer' übernommen
authorKai Moritz <kai@juplo.de>
Mon, 1 Aug 2022 21:39:56 +0000 (23:39 +0200)
committerKai Moritz <kai@juplo.de>
Mon, 1 Aug 2022 21:39:56 +0000 (23:39 +0200)
1  2 
Dockerfile
README.sh
docker-compose.yml
pom.xml

diff --cc Dockerfile
index 0000000,ea4d335..3aefb4b
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,6 +1,6 @@@
 -COPY target/dependency /opt/libs
 -ENTRYPOINT [ "java", "-jar", "/opt/app.jar", "kafka:9092", "test" ]
+ FROM openjdk:11-jre
+ VOLUME /tmp
+ COPY target/*.jar /opt/app.jar
++COPY target/libs /opt/libs
++ENTRYPOINT [ "java", "-jar", "/opt/app.jar", "kafka:9092", "test", "my-group" ]
+ CMD [ "DCKR" ]
diff --cc README.sh
+++ b/README.sh
@@@ -1,5 -1,7 +1,7 @@@
  #!/bin/bash
  
 -IMAGE=juplo/simple-producer:1.0-SNAPSHOT
++IMAGE=juplo/simple-consumer:1.0-SNAPSHOT
  if [ "$1" = "cleanup" ]
  then
    docker-compose down -v
@@@ -16,18 -24,12 +24,13 @@@ f
  
  echo "Waiting for the Kafka-Cluster to become ready..."
  docker-compose exec cli cub kafka-ready -b kafka:9092 1 60 > /dev/null 2>&1 || exit 1
+ docker-compose up setup
+ docker-compose up -d
+ sleep 5
  
- echo "Producing messages"
- mvn exec:java@producer
- echo "Reading messages"
- mvn exec:java@consumer &
- sleep 7
- kill $(jobs -p)
- sleep 2
+ docker-compose exec cli kafkacat -b kafka:9092 -t test -q -c 20 -f'topic=%t\tpartition=%p\toffset=%o\tkey=%k\tvalue=%s\n'
  
- echo "Re-Reading messages"
- mvn exec:java@consumer &
- sleep 7
- kill $(jobs -p)
- sleep 2
 -docker-compose stop producer
 -docker-compose exec cli kafkacat -b kafka:9092 -t test -q -e -f'topic=%t\tpartition=%p\toffset=%o\tkey=%k\tvalue=%s\n'
 -docker-compose logs producer
++docker-compose stop producer consumer-1 consumer-2 consumer-3
++docker-compose logs consumer-1
++docker-compose logs consumer-2
++docker-compose logs consumer-3
@@@ -35,3 -72,7 +72,19 @@@ services
    cli:
      image: juplo/toolbox
      command: sleep infinity
+   producer:
+     image: juplo/simple-producer:1.0-SNAPSHOT
+     command: producer
++
++  consumer-1:
++    image: juplo/simple-consumer:1.0-SNAPSHOT
++    command: consumer-1
++
++  consumer-2:
++    image: juplo/simple-consumer:1.0-SNAPSHOT
++    command: consumer-2
++
++  consumer-3:
++    image: juplo/simple-consumer:1.0-SNAPSHOT
++    command: consumer-3
diff --cc pom.xml
+++ b/pom.xml
    <build>
      <plugins>
        <plugin>
-         <groupId>org.codehaus.mojo</groupId>
-         <artifactId>exec-maven-plugin</artifactId>
-         <version>3.0.0</version>
+         <groupId>pl.project13.maven</groupId>
+         <artifactId>git-commit-id-plugin</artifactId>
+       </plugin>
+       <plugin>
+         <groupId>org.apache.maven.plugins</groupId>
+         <artifactId>maven-dependency-plugin</artifactId>
          <executions>
            <execution>
-             <id>producer</id>
+             <id>copy-dependencies</id>
+             <phase>package</phase>
+             <goals>
+               <goal>copy-dependencies</goal>
+             </goals>
              <configuration>
-               <mainClass>de.juplo.kafka.SimpleProducer</mainClass>
+               <outputDirectory>${project.build.directory}/libs</outputDirectory>
              </configuration>
            </execution>
-           <execution>
-             <id>consumer</id>
-             <configuration>
+         </executions>
+       </plugin>
+       <plugin>
+         <groupId>org.apache.maven.plugins</groupId>
+         <artifactId>maven-jar-plugin</artifactId>
+         <configuration>
+           <archive>
+             <manifest>
+               <addClasspath>true</addClasspath>
+               <classpathPrefix>libs/</classpathPrefix>
 -              <mainClass>de.juplo.kafka.SimpleProducer</mainClass>
 +              <mainClass>de.juplo.kafka.SimpleConsumer</mainClass>
-             </configuration>
+             </manifest>
+           </archive>
+         </configuration>
+       </plugin>
+       <plugin>
+         <groupId>io.fabric8</groupId>
+         <artifactId>docker-maven-plugin</artifactId>
+         <version>0.33.0</version>
+         <configuration>
+           <images>
+             <image>
+               <name>juplo/%a:%v</name>
+             </image>
+           </images>
+         </configuration>
+         <executions>
+           <execution>
+              <id>build</id>
+              <phase>package</phase>
+              <goals>
+                <goal>build</goal>
+              </goals>
            </execution>
          </executions>
        </plugin>