In order to make Akka Streams available in our project, we need to put the following dependency into the build.sbt file:
lazy val akkaVersion = "2.5.14"
libraryDependencies += "com.typesafe.akka" %% "akka-stream" % akkaVersion
This gives us the possibility to import related classes in our examples using the following import statements:
import akka.stream._
import akka.stream.scaladsl._
These import statements are assumed to be present in every example later in this chapter.
We will also need a wrapper which would provide an actor system in order for us to be able to create materializers for our streams. The wrapper will need to terminate the actor system as soon as stream processing is finished:
package ch13
import akka.actor.ActorSystem
import akka.stream._
object Bakery extends App {
implicit val bakery: ActorSystem = ActorSystem("Bakery")
implicit val materializer: Materializer = ActorMaterializer()
// stream processing happens here
private def afterAll = bakery.terminate()
}
Now, before we dive into the code, we need some vocabulary to be able to describe what we are doing in our examples.