This project contains an example on how to have a producer/listener using:
- kafka
- Avro messaging format
- Protocol Buffer messaging format
- Kafka test container with a mock schema registry
- Micronaut microservices
- JDK 17
- Maven
- JUnit
- AssertJ/Awaitability
- Software required
- JDK 17 (tested with GraalVM 17.0.4)
- Protocol Buffer executable (3.21.9)
- Apache maven (3.8.6)
- Docker running (tested with Docker Desktop 4.13.1)
- Micronaut
I'll do my best with keeping this tutorial up-to-date. Please write me or put in a comment if you would like me to upgrade the software list above and make appropriate changes to the code.
curl -s "https://get.sdkman.io" | bash
This installs sdkman.
Then install the following: sdk install java sdk install micronaut sdk install maven
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
NOTE: This is supposed to be a cask since it's a desktop app. Take note of the command below:
brew install --cask docker
Then make sure to start docker desktop!
brew install protobuf
git clone git@github.com:krickert/micronaut-kafka-container-test-example.git
cd micronaut-kafka-container-test-example
mvn clean compile install test
I've found a few things can dirty the environment:
The testing resources provided by micronaut are stored in ~/.micronaut. However, when the JDK default changes it tends to break the service. If tests hang, try this first.