Communicate Between Microservices with Apache Kafka

Federico Ricchiuto

Okay so I was using the full infrastructure docker-compose configuration, where kafka container was configured a little differently. So I used the kafka.yml docker-compose configuration shipped with the microservice, and it worked this time.
The difference is in this line:

KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092

In order to let a spring application (not dockerized) reach the kafka server, it should be configured as:

KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092

As you can see it points also to localhost, which is not needed in a docker-only configuration.
Hope that this can help somebody else.