Kafka is a popular publish-subscribe messaging system. JHipster has an optional support for Kafka, that will:
- Configure Kafka clients with JHipster.
- Add the necessary configuration in the
- Generate a Docker Compose configuration file, so Kafka is usable by simply typing
docker-compose -f src/main/docker/kafka.yml up -d.
Generate a new application and make sure to select
Asynchronous messages using Apache Kafka when prompted for technologies you would like to use. A Docker Compose configuration file is generated and you can start Kafka with the command:
docker-compose -f src/main/docker/kafka.yml up -d
Consumer and Producer
A consumer (
<appName>KafkaConsumer class) is running and can be adapted to your needs.
A producer (
<appName>KafkaProducer class) is also available and can be called through a REST endpoint (
Running the app
Allow access to the endpoint in
If you invoke the endpoint
http://localhost:8080/api/<appName>-kafka/publish?message=..., you should see the message logged to the console.