Skip to content

Instantly share code, notes, and snippets.

@pauca
Created March 5, 2020 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pauca/5f5e5eb14226122bc8eb62948247d05b to your computer and use it in GitHub Desktop.
Save pauca/5f5e5eb14226122bc8eb62948247d05b to your computer and use it in GitHub Desktop.
akkaQueueExample.scala
import akka.actor._
import akka.actor.ActorLogging
import akka.actor.ActorSystem
import akka.stream._
import akka.stream.actor.ActorSubscriberMessage._
import akka.stream.actor._
import akka.stream.scaladsl._
import akka.{ NotUsed, Done }
import scala.io.Source
import java.io._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent._
implicit val system = ActorSystem("AkkaStreamTemplate")
implicit val materializer = ActorMaterializer()
val queue = akka.stream.scaladsl.Source.queue[String](100, OverflowStrategy.fail)
val ( queue2 , y) =queue.map( x=> s"yyyyyyyyyyy$x").toMat( akka.stream.scaladsl.Sink.foreach( x=>println(x)))(Keep.both).run()
queue2.offer("10")
queue2.offer("20")
queue2.offer("30")
queue2.complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment