Kafka - java to scala - introduction
I was recently a participant on a Confluent on-premesis kafka course. While working through the labs (which are in java), for fun I tried the same code in kotlin. That was fun - but I thought it could be a nice exercise to convert from java to scala - step by step - and maybe learn some new scala stuff on the way. It will assume some level of kafka knowledge - what is a producer, consumer, topic etc.
It is important to understand that it is written from my viewpoint - someone who has played with scala, likes it, but has never really had time to get into it - so this will be somewhat of a discovery journey for me too.
Posts in this series
- A simple java example running - a basic producer and consumer pair
- Convert java to scala - conversion of the basic producer and consumer to scala - on an almost line by line basis
- Update the scala version to be more "scala-like" and add a config file instead of hard coded values
- A slight digression to look at basic akka-streams
- Use akka-streams for the scala example
All code is available in this github repository: https://github.com/chrissearle/kafka-java-to-scala
All of the related articles assume that you have kafka running using the supplied
docker-compose.yml file - so in the working directory - run:
Make sure you have a good amount of memory available to docker - 4-5 Gb minimum :)