14 Alpakka
This chapter covers
- Read and write from and to Kafka
- Read and write from and to CSV
Alpakka is a project that implements multiple connectors that allow you to interact with different technologies in a reactive streaming way, according to the principles of the Reactive Streams project (https://www.reactive-streams.org). For example, reading from a Kafka topic with an asynchronous stream with no blocking backpressure.
In this chapter you will cover some of the most commonly used connectors, namely Kafka and CSV. The CSV-Alpakka can be classified as finite streams because it ends after the file is read. The Kafka-Alpakka connector, on the other hand, is an example of an infinite stream where there is an open connection to a topic that can produce records at any time.
Alpakka Kafka has an extensive API and most of this chapter is dedicated to it, while the rest is dedicated to CSV which have a relatively simple API.
IMPORTANT
You can use the following code companion to check out the source code of this chapter https://github.com/franciscolopezsancho/akka-topics/tree/main/chapter14. You can find the contents of any snippet or listing in the .scala file with the same name as the class, object or trait.