Testing Micronaut Kafka Listener using Testcontainers
Table of contents
Learn how to create a Micronaut application with a Kafka listener that persists data in MySQL,
then test it using Testcontainers Kafka and MySQL modules with Awaitility.
Time to complete
25 minutes
In this guide, you'll learn how to:
- Create a Micronaut application with Kafka integration
- Implement a Kafka listener and persist data in a MySQL database
- Test the Kafka listener using Testcontainers and Awaitility
Prerequisites
- Java 17+
- Maven or Gradle
- A Docker environment supported by Testcontainers
NoteIf you're new to Testcontainers, visit the Testcontainers overview to learn more about Testcontainers and the benefits of using it.
Modules
- Create the project
Set up a Micronaut project with Kafka, Micronaut Data JPA, and MySQL.
- Write tests
Test the Micronaut Kafka listener using Testcontainers Kafka and MySQL modules with Awaitility.
- Run tests
Run your Testcontainers-based Micronaut Kafka integration tests and explore next steps.