Upload
mark-wilson
View
862
Download
0
Embed Size (px)
DESCRIPTION
Presentation for the kick-off meeting for the meetup: "Reactive Programming Enthusiasts Denver". This talks about concurrency, non-blocking, scala, futures, akka, play framework, and other concepts of reactive programming.
Citation preview
Anatomy of a Reactive Application
Reactive Programming Enthusiasts Denver Meet-up Kick-Off
Mark Wilson
Demo Application
Scala
Akka
Play!
Intended to Illustrate some concepts of Reactive Programming, Introduce:
but the demo is mostly about Non-Blocking
Amdahl’s Law“… Therefore it is important that the entire solution is
asynchronous and non-blocking. ” - Reactive Manifesto
FuturesA Future is an object holding a value which
may become available at some point. !
• A Future is either completed or not completed • A completed Future is either:
• successful (value) • or failed (exception)
! import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent._
! val fs: Future[String] = Future { “a” + “b” } fs.onComplete { case Success(x) => println(x) case Failure(e) => throw e }
The Fish Store
1. Play GET and POST, non-blocking 2. Akka Actors processing a delivery
Start from the start a most simple web page
ActorFrom the book “Akka Concurrency”
by Derek Wyatt
Web Tier (Play)
Stateless: horizontally scalable
Aims to allow concurrency throughout the application
Fits with REST/ powerful javascript
An open source web application framework, written in Scala and Java, which follows the model–view–
controller architectural pattern.
AkkaUsing the Actor Model we raise the abstraction level and
provide a better platform to build correct, concurrent, and scalable applications. - akka docs
From the book “Akka
Concurrency” by Derek Wyatt
pipeTo import akka.pattern.pipe! val future: Future[Any] = someFunctionReturningFuture() future pipeTo sender // sends to sender as Future[Any]! // is roughly equivalent to! val mysender = sender // final def sender(): ActorRef future.onComplete { case Success(x) => mysender ! x case Failure(e) => mysender ! akka.actor.Status.Failure(e) }! // if sender doesn't handle Failure(e) it is logged as unhandled
Akka More..Configuration
Akka Test Kit
Akka Extensions
Akka Traits { Stash, ActorLogging }
TypedActor
Akka Events { EventBus, EventStream } - Pub/sub behavior
Akka Scheduler - sending a message to an actor on a schedule.
Supervision/Fault Tolerance { Resume, Restart, Stop, Escalate }
Data Flows - special lib for writing futures: flow { “hi” } onComplete println
Pipeline - sequential processing within an actor
Remote Actors - utilizing actors on remote machines (or clustered machines)
“It is better to fail in originality than to succeed in imitation.”
–Herman Melville
Up Next?!
March 2014
RPED Chunk-O-Thon OneCollective 3 minute presentations
Open participation
Topics span Reactive Applications
Examples:
Working examples / Shared learning exercise
Well formed problem/question for the group
Weird, funny or unexpected behavior
Realtime UI tricks
Other interesting stuff you come up with
Submissions must be available 1 week prior to meeting
There will be prizes!
March 2014