0

i use a kafka-wurstmeister-image on docker with a bridge-network, it works fine, i can use local producer/consumer to in-&output data from kafka-topic. then i try to push my local producer/consumer/streamapi to docker-repository. After running i've got:
org.apache.kafka.common.errors.TimeoutException: Topic source-validator-topic not present in metadata after 60000 ms.
i think there must be sth wrong with my configuration.

following is my step: 1. output java producer from eclipse.
2. generate pom.xml for maven-build, and build.
3. generate Dockerfile to create image, and create.
3. push image to docker-repository.
4. generate docker-compose.yml.
5. run in CLi: docker-compose up

here is my pom.xml file:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>StreamForBC</groupId>
  <artifactId>StreamForBC</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>blockchain-docker</name>
  <url>http://maven.apache.org</url>
  <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
  </properties>
  <dependencies>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>


   <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
       <version>1.7.5</version>
   </dependency>
   <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-log4j12</artifactId>
       <version>1.7.5</version>
   </dependency>
   <dependency>
       <groupId>log4j</groupId>
       <artifactId>log4j</artifactId>
       <version>1.2.17</version>
   </dependency>



    <dependency>
        <groupId>org.apache.kafka</groupId>
        <artifactId>kafka_2.13</artifactId>
        <version>2.4.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.kafka</groupId>
        <artifactId>kafka-clients</artifactId>
        <version>2.4.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.kafka</groupId>
        <artifactId>kafka-streams</artifactId>
        <version>2.4.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.kafka</groupId>
        <artifactId>kafka-log4j-appender</artifactId>
        <version>2.4.0</version>
    </dependency>

    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.6</version>
    </dependency>
  </dependencies>


    <build>
        <finalName>blockchain-software</finalName>
        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>StreamForBC.ProducerTest</mainClass>
                            <classpathPrefix>lib/</classpathPrefix>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>

            <!-- copy dependencies / jars to ${project.build.directory}/lib/ -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.1.1</version>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>
                                ${project.build.directory}/lib/
                            </outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

here is my Dockerfile:

FROM openjdk
ARG JAR_FILE=blockchain-software.jar
ARG JAR_LIB_FILE=lib/
RUN mkdir app
WORKDIR /app
COPY blockchain-software.jar .
ADD ${JAR_LIB_FILE} lib/
EXPOSE 9092:9092
CMD ["java","-cp","blockchain-software.jar","StreamForBC.ProducerTest"]

here is my docker-compose.yml:

version: '2'
services:
  validate:
    image: billkuku/bc-validate:v1
    ports:
      - "4880:4880"
      - "4822:22"
    volumes:
      - './data:/home/blockchain/validate/data'

  testproducer:
    image: billkuku/producer:v1
    ports:
      - "9093:9093"
      - "4823:23"
    volumes:
      - './data:/home/blockchain/producer/data'


  zookeeper:
    image: wurstmeister/zookeeper
    ports:
      - "2181:2181"

  kafka:
    image: wurstmeister/kafka
    ports:
      - "9092:9092"
    environment:
      KAFKA_ADVERTISED_HOST_NAME: localhost
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      KAFKA_MESSAGE_MAX_BYTES: 2000000000
      KAFKA_CREATE_TOPICS: "source-topic:1:1,source-validator-topic:1:1,block-validator-topic:1:1,block-verifier-topic:1:1"
    depends_on:
      - zookeeper
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
MHMMMDK
  • 13
  • 4

0 Answers0