--- /dev/null
-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" ]
#!/bin/bash
-IMAGE=juplo/simple-producer:1.0-SNAPSHOT
++IMAGE=juplo/simple-consumer:1.0-SNAPSHOT
+
if [ "$1" = "cleanup" ]
then
docker-compose down -v
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
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
<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>