Hello fellow programmers!
I am learning Docker and Kafka, and would be very grateful for any help. The problem is that the application is able to connect to Kafka, but not to publish any events. Error:
org.apache.kafka.common.errors.TimeoutException: Expiring 2 record(s) for wages-local-0:120001 ms has passed since batch creation
This problem arises when Spring Boot app in one Docker container tries to publish to Kafka in other container:
version: '3'
services:
zookeeper:
image: wurstmeister/zookeeper
container_name: zookeeper
ports:
- "2181:2181"
kafka:
image: wurstmeister/kafka
container_name: kafka
hostname: kafka
ports:
- "9092:9092"
environment:
KAFKA_BROKER_ID: 1
KAFKA_ADVERTISED_PORT: 9092
KAFKA_ADVERTISED_HOST_NAME: kafka
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_LISTENERS: INTERNAL://kafka:9092
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INTERNAL:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: INTERNAL
depends_on:
- zookeeper
publisher_app:
build:
context: ./kafka-publisher
ports:
- 8080:8080
depends_on:
- "kafka"
environment:
kafka.wages-topic.bootstrap-address: kafka:9092
links:
- kafka:kafka
Here is the link to source code: https://github.com/aleksei17/springboot-rest-kafka-mysql/blob/master/docker-compose.yml