Chapter 7. Reactive streaming
This chapter covers
- Seeing the dangers of unbounded buffers
- Safeguarding your application with backpressure
- Using Akka Streams in your application
- Integrating Akka Streams with other toolkits
In chapter 6, you learned how to cross actor system boundaries and send messages to remote actors. In this chapter, you learn how to prevent an application from being overwhelmed by too many messages. The reactive approach to regulating streams of messages so that they don’t become floods is called backpressure.
Akka applies backpressure for you through Akka Streams. On the surface, Akka Streams is similar to other libraries you may have encountered, such as the java.util.stream package introduced in Java 8. You can take advantage of it directly by assembling stream sources, sinks, flows, and graphs without having to worry much about what’s happening below the surface, as shown in section 7.3. Alternatively, you can use toolkits that are built on top of it, such as Akka HTTP (which we cover in chapter 9).
After learning about the Akka Streams library, you take it to the next level with the Reactive Streams application programming interface (API), which provides a standard interface to asynchronous streams and, as part of the specification, requires nonblocking backpressure. Reactive Streams is supported by many toolkits, including Akka, Java 9, and .NET. You can use it to integrate with other systems and apply backpressure across the connection.