Slide 1

Slide 1 text

Play and Reactive Streams in 3 minutes Yuta Okamoto (@okapies)
 2015/07/05

Slide 2

Slide 2 text

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… :(

Slide 3

Slide 3 text

Abstract Understand ! ! ! in 3 minutes. Reactive Streams

Slide 4

Slide 4 text

Experimental in Play 2.4 https://www.playframework.com/documentation/2.4.x/Highlights24 Provide transformation from Iteratee to the RS

Slide 5

Slide 5 text

Migration step by step: Reactive Netty https://github.com/playframework/playframework/issues/4727

Slide 6

Slide 6 text

What will happen after 2.5? 1. Netty backend → Akka HTTP backend 2. Iteratee → Accumulator with Akka Streams

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

Play turns into fully Akka based http://www.slideshare.net/Typesafe_Inc/reactive-streams-100-and-why-you-should-care-webinar/39

Slide 9

Slide 9 text

Everything becomes Stream ( ʈωʈ)
 ⊃⊂ Make this … http://www.slideshare.net/rolandkuhn/akka-streams-and-http Spary (former Akka HTTP)
 has the following problem… F ×

Slide 10

Slide 10 text

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 ×

Slide 11

Slide 11 text

Everything becomes Akka http://tech.iheart.com/post/121599571574/why-we-picked-akka-cluster-as-our-microservice Become part of cluster?

Slide 12

Slide 12 text

The challenge of
 Asynchronous stream processing • Huge data spikes make buffer of subscribers overflowing to blow up our pipeline … > Publisher Subscriber

Slide 13

Slide 13 text

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…

Slide 14

Slide 14 text

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