streams - qcon · 2015. 9. 15. · • akka http • akka tcp stream • inputstreamsource &...
TRANSCRIPT
![Page 1: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/1.jpg)
√Deputy CTO
streaming data transformation á la cartestreams
![Page 2: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/2.jpg)
2
Think of “the concept of streams” as
• ephemeral, time-dependent, sequences of elements
• possibly unbounded in length
• in essence: transformation & transportation of data
«You cannot step twice into the same stream. For as you are stepping in, other waters are ever
flowing on to you.» — Heraclitus
#protip
![Page 3: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/3.jpg)
• Simple message-oriented programming model for building Reactive applications
• Usable from both Java and Scala
• Raised abstraction levels • Never think in terms of shared state, memory visibility, threads, locks,
concurrent collections, thread notifications • High CPU utilization, low latency, high throughput, and elasticity as result
• Applications are made resilient through supervisor hierarchies
3
![Page 4: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/4.jpg)
4
actors
• Akka's unit of computation is called an Actor • Akka Actors are purely reactive components: • an address • a mailbox • a current behavior • local storage
• Scheduled to run when sent a message • Each actor has a parent, handling its failures • Each actor can have 0..N “child” actors
![Page 5: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/5.jpg)
5
« 2500 nodes × millions of actors per GB RAM = a lot» — √
actors
• An actor processes a message at a time • Multiple-producers & Single-consumer
• The overhead per actor is about ~450bytes • Run millions of actors on commodity hardware
• Akka Cluster currently handles ~2500 nodes
actors
![Page 6: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/6.jpg)
streams
![Page 7: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/7.jpg)
i m m u t a b l e
REUSABLE c o m p o s a b l e c o o r d i n a t e d asynchronoustransformations
![Page 8: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/8.jpg)
Flows
![Page 9: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/9.jpg)
9
streams: Linear transformations
• Time-Agnostic
• map, mapConcat, filter, collect, grouped, drop, take, groupBy, …
• Time-Sensitive
• takeWithin, dropWithin, groupedWithin, …
• Rate-Detached
• expand, conflate, buffer, …
• Asynchronous
• mapAsync, mapAsyncUnordered, …
![Page 10: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/10.jpg)
Sources
![Page 11: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/11.jpg)
11
streams: Sources
• org.reactivestreams.Publisher[T]
• () => Iterator[T] / immutable.Iterable[T]
• scala.concurrent.Future[T]
• actorPublisher / subscriber / actorRef
• single/empty/failed/timer/…
• …or create your own!
![Page 12: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/12.jpg)
Sinks
![Page 13: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/13.jpg)
13
streams: Sinks
• org.reactivestreams.Subscriber[T]
• foreach / fold / onComplete
• actorSubscriber / actorRef /
• ignore / publisher / fanoutPublisher / head / cancelled / …
• … or create your own!
![Page 14: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/14.jpg)
Fan-In
Fan-Out&
![Page 15: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/15.jpg)
• merge
• mergePreferred
• concat
• zip & zipWith
• … or create your own!
15
streams: Nonlinear transformations
• broadcast
• route
• balance
• unzip
• … or create your own!
![Page 16: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/16.jpg)
Fan-tastic!
![Page 17: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/17.jpg)
17
streams: Nonlinear transformations
• BidiFlow
• FlowGraph.Builder
• Custom Stages
• Coming: Octopus (“Kraken”) / N:M-way
• … and more!
![Page 18: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/18.jpg)
OI
![Page 19: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/19.jpg)
19
streams: Output & Input
• Akka Http
• Akka Tcp Stream
• InputStreamSource & OutputStreamSink
• Reactive Streams interop
• … create some of your own!
![Page 20: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/20.jpg)
Materialization
![Page 21: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/21.jpg)
21
streams: Materialization
• Akka Streams separate the what from the how
• declarative Source/Flow/Sink DSL to create a blueprint
• ActorFlowMaterializer turns this into running Actors
• enables customizable materialization strategies
• optimization
• verification / validation
• distributed deployment
• only Akka Actors (for now)
![Page 22: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/22.jpg)
live
timedemo
![Page 23: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/23.jpg)
23
Klang’s conjecture
«If you cannot solve a problem without programming; you cannot solve a problem with programming.»
![Page 24: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/24.jpg)
Getting data across an asynchronous b o u n d a r y
![Page 25: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/25.jpg)
![Page 26: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/26.jpg)
![Page 27: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/27.jpg)
![Page 28: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/28.jpg)
Getting data across an asynchronous b o u n d a r y with non-blockingback pressure
![Page 29: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/29.jpg)
29
Requirements Push Pull
support potentially unbounded sequences :) :)
sender runs separately from receiver :) :)rate of reception may vary from rate of sending :) :)
dropping elements should be a choice and not a necessity :( :)
minimal (if any) overhead in terms of latency and throughput :) :(
Comparing Push vs Pull
!
!
![Page 30: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/30.jpg)
&30
Supply
Demand
![Page 31: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/31.jpg)
31
Publisher Subscriber
data
demand
![Page 32: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/32.jpg)
• “push” when subscriber is faster
• “pull” when publisher is faster
• switches automatically between both
• batching demand allows batching ops
32
DynamicPush–Pull
![Page 33: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/33.jpg)
33
Requirements Push Pull Both
support potentially unbounded sequences :) :) :)
sender runs separately from receiver :) :) :)rate of reception may vary from rate of sending :) :) :)
dropping elements should be a choice and not a necessity :( :) :)
minimal (if any) overhead in terms of latency and throughput :) :( :)
Comparing Push vs Pull vs Both
![Page 34: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/34.jpg)
Stream splitting
34
demand
data
splitting the data means merging the demand
![Page 35: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/35.jpg)
Stream merging
35
merging the data means splitting the demand
![Page 36: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/36.jpg)
Reactive Streams Initiative
T H E
![Page 37: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/37.jpg)
The traits of Reactive
![Page 38: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/38.jpg)
38
• define minimal interfaces—essentials only • outline rigorous specification of semantics • create a TCK for verification of implementation • ensure complete freedom for many idiomatic APIs • verify that the specification is efficiently implementable
«Reactive Streams is an initiative to provide a standard for asynchronous stream processing with
non-blocking back pressure on the JVM.» — reactive-streams.org
![Page 39: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/39.jpg)
Collaboration between Engineers
39
• Björn Antonsson – Typesafe Inc.
• Gavin Bierman – Oracle Inc.
• Jon Brisbin – Pivotal Software Inc.
• George Campbell – Netflix, Inc
• Ben Christensen – Netflix, Inc
• Mathias Doenitz – spray.io
• Marius Eriksen – Twitter Inc.
• Tim Fox – Red Hat Inc.
• Viktor Klang – Typesafe Inc.
• Dr. Roland Kuhn – Typesafe Inc.
• Doug Lea – SUNY Oswego
• Stephane Maldini – Pivotal Software Inc.
• Norman Maurer – Red Hat Inc.
• Erik Meijer – Applied Duality Inc. • Todd Montgomery – Kaazing Corp.
• Patrik Nordwall – Typesafe Inc.
• Johannes Rudolph – spray.io
• Endre Varga – Typesafe Inc.
![Page 40: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/40.jpg)
ExcitingOpportunities
![Page 41: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/41.jpg)
Opportunity: Self-tuning back pressure
41
• Each processing stage can know • Latency between requesting more and getting more • Latency for internal processing • Behavior of downstream demand • Latency between satisfying and receiving more • Trends in requested demand (patterns)
• Lock-step • N-buffered • N + X-buffered • “chaotic”
![Page 42: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/42.jpg)
Opportunity: Operation elision
42
• Compile-time, using Scala Macros • fold ++ take(n where n > 0) == fold • drop(0) == identity • <any> ++ identity == <any>
• Run-time, using intra-stage simplification • map ++ dropUntil(cond) ++ take(N) • map ++ identity ++ take(N) • map ++ take(N)
![Page 43: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/43.jpg)
Opportunity: Operation fusion
43
• Compile-time, using Scala Macros • filter ++ map == collect
• Run-time, using intra-stage simplification • Rule: <any> ++ identity == <any>
Rule: identity ++ <any> == <any> • filter ++ dropUntil(cond) ++ map • filter ++ identity ++ map == collect
![Page 44: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/44.jpg)
Opportunity: Execution optimization
44
• synchronous intra-stage execution N steps then trampoline and/or give control to other Thread / Flow
![Page 45: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/45.jpg)
45
Try Akka Streams: (1.0-RC3)https://github.com/typesafehub/activator-akka-stream-scala
References
Reactive Streams for JVMhttps://github.com/reactive-streams/reactive-streams-jvm
![Page 46: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/46.jpg)
©Typesafe 2015 – All Rights Reserved
√
![Page 47: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/47.jpg)
Reactive Streamsprotocol
![Page 48: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/48.jpg)
48
public interface Publisher<T> { public void subscribe(Subscriber<T> s); } public void Subscription { public void request(long n); public void cancel(); } public interface Subscriber<T> { public void onSubscribe(Subscription s); public void onNext(T t); public void onError(Throwable t); public void onComplete(); } public interface Processor<T, R> extends Subscriber<T>, Publisher<R> { }
![Page 49: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/49.jpg)
How does it connect?
49
SubscriberPublisher
subscribe(subscriber)
onSubscribe(subscription)
![Page 50: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/50.jpg)
How does data flow?
50
SubscriberPublisher
subscription.request(1)
onNext(element)
subscription.request(3)
onNext(element)
subscription.request(1)
![Page 51: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/51.jpg)
How does data flow?
51
SubscriberPublisher
onNext(element)
onNext(element)
subscription.request(2)
onNext(element)
onNext(element)
![Page 52: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/52.jpg)
How does it complete?
52
SubscriberPublisher
subscription.request(1)
onNext(element)
onComplete()
onNext(element)
![Page 53: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/53.jpg)
What if it fails?
53
SubscriberPublisher
subscription.request(1)
onNext(element)
subscription.request(5)
onError(exception)
☠
![Page 54: streams - QCon · 2015. 9. 15. · • Akka Http • Akka Tcp Stream • InputStreamSource & OutputStreamSink • Reactive Streams interop • … create some of your own! Materialization](https://reader036.vdocuments.site/reader036/viewer/2022071410/610408373bf8d46827399140/html5/thumbnails/54.jpg)
live
timedemo