In this post, I’ll walk through a sample implementation of Kafka Streams to maintain an Event Projection. I’ll use this to illustrate when this is a suitable approach to use.
I’ve written similar Event Projection posts about sample implementations that use an in-memory lookup table, and a PostgreSQL database.
The objective for this demo
I introduced the pattern of Event Projections in Comparing approaches to maintaining an Event Projection from Kafka topics.
I also explained the scenario that I’ve been using for each of my Event Projections demos. If you haven’t seen my other posts, it may help to go back and see the scenario detail and motivation first.
In short, I’m showing how to maintain a projection of two Kafka topics (one based on the event key, the other based on an attribute in the event payload). And I’m showing how an application could make an HTTP/REST call to retrieve the data from the most recent event that matches some query.
At a high-level, the goal for this demo is to:
- use Kafka Streams to maintain a projection of the Kafka topics
- provide an HTTP/REST API for querying the projection