Yes, it's possible. Check out Source.Queue
:
Source.Queue
can be used for emitting elements to a stream from an actor (or from anything running outside the stream). The elements will be buffered until the stream can process them. You can Offer
elements to the queue and they will be emitted to the stream if there is demand from downstream, otherwise they will be buffered until request for demand is received.
Another option is Source.ActorRef
:
Messages sent to the actor that is materialized by Source.ActorRef
will be emitted to the stream if there is demand from downstream, otherwise they will be buffered until request for demand is received.
Unlike Source.Queue
, Source.ActorRef
does not support backpressure.