How it works...
In this recipe, we demonstrated how to make Akka actors interact with streams. To begin with, we created a SourceActor responsible for pushing data into the stream. Akka Streams provides a Source.queue approach, where a queue is used to buffer elements while the stream is working on processing other elements. When instantiating the queue, you provide a buffer size and OverflowStrategy. This overflow strategy defines how the queue should behave when the buffer is full and you try to insert new elements. We used backpressure to slow down the producer of data and avoid the dropping of elements. However, other strategies allow you to drop elements from the buffer or even the whole buffer. You use queue.offer to push an element ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access