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.
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
Anatomy of a Reactive Application
1. Anatomy of a
Reactive Application
Reactive Programming Enthusiasts Denver
Meet-up Kick-Off
Mark Wilson
2. Demo Application
Intended to Illustrate some concepts of Reactive
Programming, Introduce:
Scala
Akka
Play!
but the demo is mostly about Non-Blocking
3. Amdahl’s Law
“… Therefore it is important that the entire solution is
asynchronous and non-blocking. ” - Reactive Manifesto
4. Futures
A 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
}
5. 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
7. Web Tier (Play)
An open source web application framework, written in
Scala and Java, which follows the model–view–
controller architectural pattern.
Stateless: horizontally scalable
Aims to allow concurrency throughout
the application
Fits with REST/ powerful javascript
8. Akka
Using 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
9. 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
10. 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.
Super vision/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)
11. “It is better to fail in originality
than to succeed in imitation.”
–Herman Melville
13. RPED Chunk-O-Thon One
March 2014
Collective 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!