reactiveness all the way - sw architecture 2015 conference
TRANSCRIPT
![Page 1: Reactiveness All The Way - SW Architecture 2015 Conference](https://reader034.vdocument.in/reader034/viewer/2022051707/58eeec181a28ab44208b45db/html5/thumbnails/1.jpg)
Tamir DresherSenior Software ArchitectNovember 2015
Reactiveness All The Way
![Page 2: Reactiveness All The Way - SW Architecture 2015 Conference](https://reader034.vdocument.in/reader034/viewer/2022051707/58eeec181a28ab44208b45db/html5/thumbnails/2.jpg)
About Me
• Software architect, consultant and instructor• Software Engineering Lecturer @ Ruppin Academic Center• Reactive Extensions in Action (Manning)
@[email protected]://www.TamirDresher.com.
![Page 3: Reactiveness All The Way - SW Architecture 2015 Conference](https://reader034.vdocument.in/reader034/viewer/2022051707/58eeec181a28ab44208b45db/html5/thumbnails/3.jpg)
3
Software Architecture is like Pasta
By @benorama
![Page 4: Reactiveness All The Way - SW Architecture 2015 Conference](https://reader034.vdocument.in/reader034/viewer/2022051707/58eeec181a28ab44208b45db/html5/thumbnails/4.jpg)
4
Socialmedia
Stock tickers
RSS feeds
GPS
Server managementUI e
vents
Your System
![Page 5: Reactiveness All The Way - SW Architecture 2015 Conference](https://reader034.vdocument.in/reader034/viewer/2022051707/58eeec181a28ab44208b45db/html5/thumbnails/5.jpg)
5
Being Reactive
Responsive
Resilience
React to users
React to failures
http://www.reactivemanifesto.org/
![Page 6: Reactiveness All The Way - SW Architecture 2015 Conference](https://reader034.vdocument.in/reader034/viewer/2022051707/58eeec181a28ab44208b45db/html5/thumbnails/6.jpg)
6
Resiliency
You know you have a distributed system when the crash of a computer you’ve never heard of stops
you from getting any work done.
- Leslie Lamport -
![Page 7: Reactiveness All The Way - SW Architecture 2015 Conference](https://reader034.vdocument.in/reader034/viewer/2022051707/58eeec181a28ab44208b45db/html5/thumbnails/7.jpg)
7
Being Reactive
Responsive
Resilience
React to users
React to failures
![Page 8: Reactiveness All The Way - SW Architecture 2015 Conference](https://reader034.vdocument.in/reader034/viewer/2022051707/58eeec181a28ab44208b45db/html5/thumbnails/8.jpg)
8
Being Reactive
Responsive
Resilience
Message Driven
React to users
React to failures
React to messages
![Page 9: Reactiveness All The Way - SW Architecture 2015 Conference](https://reader034.vdocument.in/reader034/viewer/2022051707/58eeec181a28ab44208b45db/html5/thumbnails/9.jpg)
9
Being Reactive
Responsive
Elastic Resilience
Message Driven
React to users
React to failuresReact to load
React to messages
![Page 10: Reactiveness All The Way - SW Architecture 2015 Conference](https://reader034.vdocument.in/reader034/viewer/2022051707/58eeec181a28ab44208b45db/html5/thumbnails/10.jpg)
10
Being Reactive
Responsive
Elastic Resilience
Message Driven
React to users
React to failuresReact to load
React to messages
![Page 11: Reactiveness All The Way - SW Architecture 2015 Conference](https://reader034.vdocument.in/reader034/viewer/2022051707/58eeec181a28ab44208b45db/html5/thumbnails/11.jpg)
11
Reacting to Changes (notifications) with Rx• Observables• Observers• Operators• www.ReactiveX.io
g(x)
f(x)UI eve
nts
Stock tickers
![Page 12: Reactiveness All The Way - SW Architecture 2015 Conference](https://reader034.vdocument.in/reader034/viewer/2022051707/58eeec181a28ab44208b45db/html5/thumbnails/12.jpg)
12
Rx Example
1. At least 4 characters2. Don’t overflow server (0.5 sec delay)3. Don’t send the same string again4. Discard results if another search was requested
![Page 13: Reactiveness All The Way - SW Architecture 2015 Conference](https://reader034.vdocument.in/reader034/viewer/2022051707/58eeec181a28ab44208b45db/html5/thumbnails/13.jpg)
13
Rx Example
Rx.Observable.fromEvent($('#input'),'keyup') .map(e => e.target.value) .filter(text => text.length > 3) .throttle(500 /* ms */) .distinctUntilChanged() .flatMapLatest(searchWikipedia) .subscribe( data => { /* handle the results */}, error => { /* handle any errors */});
Observable.FromEventPattern(txtBox,“TextChanged”) .Select(_ => txtBox.Text); .Where(txt => txt.Length > 3); .Throttle(TimeSpan.FromSeconds(0.5)) .DistinctUntilChanged() .Select(text => SearchAsync(text)) .Switch() .Subscribe(
results => { /* handle the results */ },ex => { /* handle any errors */ } );
RxJS Rx.NET
![Page 14: Reactiveness All The Way - SW Architecture 2015 Conference](https://reader034.vdocument.in/reader034/viewer/2022051707/58eeec181a28ab44208b45db/html5/thumbnails/14.jpg)
14
Back Pressure
3 per sec 1 per sec
http://www.reactive-streams.org/
Publisher Subscriber
demand
• “Push” behavior when consumer is faster
• “Pull” behavior when producer is faster
![Page 15: Reactiveness All The Way - SW Architecture 2015 Conference](https://reader034.vdocument.in/reader034/viewer/2022051707/58eeec181a28ab44208b45db/html5/thumbnails/15.jpg)
15
The Actor Model (Hewitt et al. 1973)
Alice
Mailbox
Bob
Sally
Mailbox
Mailbox
“the Actor model retained more of what I thought
were the good features of the object idea.”
Alan Kay Object Orientation pioneer and Smalltalk co-designer
AliceParent
BobParent
SallyParent
![Page 16: Reactiveness All The Way - SW Architecture 2015 Conference](https://reader034.vdocument.in/reader034/viewer/2022051707/58eeec181a28ab44208b45db/html5/thumbnails/16.jpg)
16
Akka Exampleclass SimpleActor extends Actor { override def receive: Receive = { case x => println("Received message: " + x) }}
object Main extends App { val system = ActorSystem(“actor-system") val anActor: ActorRef = system.actorOf(Props[SimpleActor]) anActor ! "Hello world" }
akka { actor.deployment { /simpleActor { remote = "akka://[email protected]:3232" } }}
![Page 17: Reactiveness All The Way - SW Architecture 2015 Conference](https://reader034.vdocument.in/reader034/viewer/2022051707/58eeec181a28ab44208b45db/html5/thumbnails/17.jpg)
17
Akka Parental Supervision
override val supervisorStrategy = OneForOneStrategy(maxNrOfRetries = 10, withinTimeRange = 1 minute) { case _: ArithmeticException => Resume case _: NullPointerException => Restart case _: IllegalArgumentException => Stop case _: Exception => Escalate }
1. OneForOneStrategy – affect only the failing child2. AllForOneStrategy – affects the failing child & it’s siblings
Child
Parent
Child
![Page 18: Reactiveness All The Way - SW Architecture 2015 Conference](https://reader034.vdocument.in/reader034/viewer/2022051707/58eeec181a28ab44208b45db/html5/thumbnails/18.jpg)
18
Summary
manning.com/dresherDiscount code: ctwswarch
http://www.reactivemanifesto.org/
Actor Model
![Page 19: Reactiveness All The Way - SW Architecture 2015 Conference](https://reader034.vdocument.in/reader034/viewer/2022051707/58eeec181a28ab44208b45db/html5/thumbnails/19.jpg)
Presenter contact detailst: @tamir_dreshere: [email protected]: TamirDresher.comw: www.codevalue.net