Open alagiz opened 4 years ago
here's my setup:
# ================== build image ==================
FROM ubuntu:bionic AS BUILD
ADD https://cmake.org/files/v3.15/cmake-3.15.5-Linux-x86_64.sh /cmake-3.15.5-Linux-x86_64.sh RUN mkdir /opt/cmake RUN sh /cmake-3.15.5-Linux-x86_64.sh --prefix=/opt/cmake --skip-license RUN ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake RUN cmake --version
RUN apt-get update && apt-get install -y build-essential libgl1-mesa-dev curl unzip tar git libboost-all-dev \ librdkafka-dev libssl-dev freeglut3 libglu1-mesa-dev \ freeglut3-dev libturbojpeg0-dev && rm -rf /var/lib/apt/lists/*
RUN git clone https://github.com/mfontanini/cppkafka.git RUN cd cppkafka && mkdir build && cd build && cmake .. && make && make install
COPY src/messaging/consumer/consumer.cpp /cppkafka/
RUN cd cppkafka && g++ consumer.cpp -std=c++17 -lpthread -lz -lstdc++ -lcppkafka -lrdkafka -o main
FROM ubuntu:bionic
RUN apt-get update && apt-get install -y librdkafka-dev
ENV LD_LIBRARY_PATH /usr/local/lib:$LD_LIBRARY_PATH
COPY --from=BUILD /cppkafka/build/* /usr/app/ COPY --from=BUILD /cppkafka/main /usr/app/ COPY --from=BUILD /usr/local/lib/libcppkafka.so /usr/local/lib/ COPY --from=BUILD /usr/local/lib/libcppkafka.so.0.3.1 /usr/local/lib/
WORKDIR /usr/app
CMD ["./main"]
* docker-compose file i am using
```yaml
version: '3.2'
services:
zookeeper:
image: wurstmeister/zookeeper
ports:
- "2181:2181"
kafka:
image: wurstmeister/kafka
depends_on:
- "zookeeper"
environment:
KAFKA_ADVERTISED_HOST_NAME: kafka
KAFKA_ADVERTISED_PORT: "9092"
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_HEAP_OPTS: -Xmx256m -Xms256m
KAFKA_NUM_PARTITIONS: 2
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- "9092:9092"
performer:
image: kafka-utils
command: ["java", "-jar", "/app.jar"]
ports:
- "3103:8080"
consumer-0:
image: consumer
command: sh -c "
sleep 15 && ./main"
depends_on:
- kafka
consumer-1:
image: consumer
command: sh -c "
sleep 15 && ./main"
depends_on:
- kafka
docker-compose up
# get id of running containers
docker ps
docker stop
* to bring the consumer back to life
```bash
docker start <id-of-consumer-0>
hello,
i have several consumers in the same consumer group, when a consumer goes offline and comes back online - it still gets old messages.
was trying to follow directions given in https://github.com/mfontanini/cppkafka/issues/243 and https://github.com/mfontanini/cppkafka/issues/244 but still getting old messages when a consumer comes back online.
would appreciate any pointers at the potential solution.
here's my code:
code
```cpp #includehere are the logs for 1 consumer: