Accessing the underlying ActorRef of an akka stream Source created by Source.actorRef

前端 未结 3 1961
情歌与酒
情歌与酒 2020-11-30 06:04

I\'m trying to use the Source.actorRef method to create an akka.stream.scaladsl.Source object. Something of the form

import akka.stream.OverflowStrategy.fai         


        
3条回答
  •  旧巷少年郎
    2020-11-30 06:19

    As @Noah points out the experimental nature of akka-streams, his answer might not work with the 1.0 release. I had to follow the example given by this example:

    implicit val materializer = ActorMaterializer()
    val (actorRef: ActorRef, publisher: Publisher[TweetInfo]) = Source.actorRef[TweetInfo](1000, OverflowStrategy.fail).toMat(Sink.publisher)(Keep.both).run()
    actorRef ! TweetInfo(...)
    val source: Source[TweetInfo, Unit] = Source[TweetInfo](publisher)
    

提交回复
热议问题