Play and Reactive Streams (English version)

Play and Reactive Streams (English version)

In Play meetup 2 (2015/07/05) by @okapies

※ This is just a complementary material of "Introduction to Reactive Streams" ( The English version will be published in a few days or weeks :)


Yuta Okamoto

July 06, 2015


  1. 2.

    Note • This is a backup material for “play meetup

    2”, complementing "Introduction to Reactive Streams" originally given at JJUG (Japan Java Users Group) Night Seminar in 6/24 • English version is now in preparation… :(
  2. 6.

    What will happen after 2.5? 1. Netty backend → Akka

    HTTP backend 2. Iteratee → Accumulator with Akka Streams
  3. 7.

    Accumulator final class Accumulator[-E, +A](sink: Sink[E, Future[A]]) { def map[B](f:

    A => B) (implicit executor: ExecutionContext): Accumulator[E, B] def recoverWith[B >: A](pf: PartialFunction[Throwable, Future[B]]) (implicit executor: ExecutionContext): Accumulator[E, B] ! def run(source: Source[E, _]) (implicit materializer: Materializer): Future[A] =
 source.toMat(sink)(Keep.right).run() } Materialize
 stream of E (multiple values)
 into Future[A] (single value) • Thin wrapper for Sink of Akka Streams • Transform accumulated elements into Future play-streams: play.api.libs.streams.Accumulator
  4. 10.

    Everything becomes Stream ( ʈωʈ)
 ⊃ ⊂ … like this. Handle large files, chunks,
 and WebSocket frames
 in a unified manner F ×
  5. 12.

    The challenge of
 Asynchronous stream processing • Huge data spikes

    make buffer of subscribers overflowing to blow up our pipeline … > Publisher Subscriber
  6. 13.

    Reactive Streams • Reactive Streams offer a great solution to

    the issue of flow control in asynchronous stream processing field, by exploiting back-pressure mechanism ! To be continued…
  7. 14.

    Reference • “Play 3 Implementation Plan” d/1OejviUX5TDlRVeKg1JD9L4qh2Tn21giItmyxRXCydN0/ edit#heading=h.l3a9tmzfgjwy •

    “Play 2.4 Moves to Dependency Injection and Java 8" http:// • “Reactive Streams and Play 3.0” streams/ • “Play, Akka streams, and reactive streams” https://!topic/play-framework-dev/ tiHAe23PryQ