Skip to content

integration test to validate that a kafka message was published by read side processor using alpakka

License

Notifications You must be signed in to change notification settings

gastonschabas/poc-lagom-alpakka-it-test

Repository files navigation

POC Lagom Alpakka IT Test

An integration test to validate that a kafka message was published by read side processor using alpakka

Table of Contents

Requirements

Description

A POC to start a Kafka Container, a PostrgeSQL Container and a Lagom Application to persist en event in the event journal, publish a kafka message in a topic and consume it in an Integration Test

How the project is built

Stack

PocServiceLoader

The entry point of the application. Once we start the service it will execute this class to instantiate all the required components such as the KafkaProducer that publish messages in a kafka topic and also registers the read side processor.

KafkaHelper

It contains the logic to start a Producer and publish a kafka message in a topic.

PocHelloMessagePublisher

Each time an event is persisted, it will use the KafkaHelper to publish the message in Kafka.

Integration Test

PocHelloMessagePublisherTest - It starts a Kafka and PostgreSQL containers, then starts the Lagom Application using the PocServiceLoader as a Loader class where it instantiates all the required components such as the KafkaHelper and register PocHelloMessagePublisher as a read side processor. With the ReadSideTestDriver it simulates that an event was persisted in the event journal. Doing that the read side processor will pick up that event and publish a message in a kafka topic. Then a Consumer will subscribe to the same topic to be able to consume that message. The test can be executed using the following command

sbt test

In the log messages you would be able to see the kafka and postgresql containers starting, then the service application, followed by the kafka producer and finally the test starting the consumer to validate that the message was published in the topic as expected

About

integration test to validate that a kafka message was published by read side processor using alpakka

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages