When MyActor
receive the Start
message, it runs an Akka Stream
, and publish each item received to the Akka Event Stream
.
class MyActor (implicit system: ActorSystem, materialize: Materializer, ec: ExecutionContext) extends Actor {
override def receive: Receive = {
case Start =>
someSource
.toMat(Sink.foreach(item => system.eventStream.publish(item)))(Keep.left)
.run()
}
}
Now in another block of code I would like to build a Source
from those items from that event stream, so every item published can be processed in another Akka Stream
.
How can I do that ?
Just in case it might add more options, note that the other block of code in question is a Play framework
's Websocket handler.
system.eventStream.publish(item)
outside of an actor)? – Ivan StanislavciucSource.fromAkkaEvent[classOf[Item]]
or can we build that ? – acmouneSource.queue
but, the main issue is that only an Actor can subscribe to the ActorSytem's Event Stream. I really want to do with the Event Stream because I want to keep the publisher and subscriber decoupled. I think I need to find a way to integrate an Actor in the Stream processing. – acmoune