Developing Akka Dynamic Streams
Before integrating Akka Streams into our Play web application, in this section, we will develop and explore Akka Streams Dynamic components with one simple example.
Perform the following steps to explore Akka Streams Dynamic components:
- Create a Scala SBT project in your favorite IDE:
Project Name: akka-dynamic-streams-scala-app.
- Add the
akka-streams
dependency in thebuild.sbt
file as shown here:
build.sbt
name := "akka-dynamic-streams-scala-app" version := "1.0.0" scalaVersion := "2.12.4" libraryDependencies ++= Seq( "com.typesafe.akka" %% "akka-stream" % "2.5.9" )
- Develop and test
AkkaStreamsMergeHubApp
, as shown here:
object AkkaStreamsMergeHubApp extends App{ implicit val actorSystem = ActorSystem("MergeHubSystem") implicit val materializer = ActorMaterializer() val consumer = Sink.foreach(println) val mergeHub = MergeHub.source[String](perProducerBufferSize = 16) val runnableGraph...