Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Play and Reactive Streams (English version)

Play and Reactive Streams (English version)

In Play meetup 2 (2015/07/05) by @okapies
https://playframeworkja.doorkeeper.jp/events/27023

※ This is just a complementary material of "Introduction to Reactive Streams" (https://speakerdeck.com/okapies/reactive-streams-ru-men-number-jjug) The English version will be published in a few days or weeks :)

Yuta Okamoto

July 06, 2015
Tweet

More Decks by Yuta Okamoto

Other Decks in Programming

Transcript

  1. 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. What will happen after 2.5? 1. Netty backend → Akka

    HTTP backend 2. Iteratee → Accumulator with Akka Streams
  3. 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. Everything becomes Stream ( ʈωʈ)
 ⊃ ⊂ … like this.

    http://www.slideshare.net/rolandkuhn/akka-streams-and-http Handle large files, chunks,
 and WebSocket frames
 in a unified manner F ×
  5. The challenge of
 Asynchronous stream processing • Huge data spikes

    make buffer of subscribers overflowing to blow up our pipeline … > Publisher Subscriber
  6. 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. Reference • “Play 3 Implementation Plan” https://docs.google.com/document/ d/1OejviUX5TDlRVeKg1JD9L4qh2Tn21giItmyxRXCydN0/ edit#heading=h.l3a9tmzfgjwy •

    “Play 2.4 Moves to Dependency Injection and Java 8" http:// www.infoq.com/news/2015/06/play-24-dependency-injection • “Reactive Streams and Play 3.0” http://jroper.github.io/play3- streams/ • “Play, Akka streams, and reactive streams” https:// groups.google.com/forum/#!topic/play-framework-dev/ tiHAe23PryQ