Reactive Web Applications
Covers Play, Akka, and Reactive Streams
Manuel Bernhardt
Foreword by James Roper
  • June 2016
  • ISBN 9781633430099
  • 328 pages
  • printed in black & white

You‘ll come away with a solid understanding of how reactive web applications are architected, developed, tested, and deployed.

From the Foreword by James Roper, lead developer of the Play Framework

Reactive Web Applications teaches web developers how to benefit from the reactive application architecture and presents hands-on examples using the Play framework.

About the Technology

Reactive applications build on top of components that communicate asynchronously as they react to user and system events. As a result, they become scalable, responsive, and fault-tolerant. Java and Scala developers can use the Play Framework and the Akka concurrency toolkit to easily implement reactive applications without building everything from scratch.

About the book

Reactive Web Applications teaches web developers how to benefit from the reactive application architecture and presents hands-on examples using Play, Akka, Scala, and Reactive Streams. This book starts by laying out the fundamentals required for writing functional and asynchronous applications and quickly introduces Play as a framework to handle the plumbing of your application. The book alternates between chapters that introduce reactive ideas (asynchronous programming with futures and actors, managing distributed state with CQRS) and practical examples that show you how to build these ideas into your applications.

Table of Contents detailed table of contents

Part One

1. Did you say reactive?

1.1. Putting reactive into context

1.1.1. Origins of reactive

1.1.2. The Reactive Manifesto

1.1.3. Reactive programming

1.1.4. The emergence of reactive technologies

1.2. Re-thinking computational resource utilization

1.2.1. Threaded versus evented web-application servers

1.2.2. Developing web-applications fit for multi-core architectures

1.2.3. The horizontal application architecture

1.3. Failure handling as first-class concern

1.3.1. Failure is inevitable

1.3.2. Building applications with failure in mind

1.3.3. Dealing with load

1.4. Summary

2. Your first reactive web application

2.1. Creating and running a new project

2.2. Connecting to Twitter's streaming API

2.2.1. Getting the connection credentials to the Twitter API

2.2.2. Working around a bug with OAuth authentication

2.2.3. Streaming data from the Twitter API

2.2.4. Asynchronously transforming the twitter stream

2.3. Streaming tweets to clients using a WebSocket

2.3.1. Creating an actor

2.3.2. Setting up the WebSocket connection and interacting with it

2.3.3. Sending tweets to the WebSocket

2.4. Making the application resilient and scaling out

2.4.1. Making the client resilient

2.4.2. Scaling out

2.5. Summary

3. Functional programming primer

3.1. A few words on functional programming

3.2. Immutability

3.2.1. The fallacy of mutable state

3.2.2. Immutable values as snapshots of reality

3.2.3. Expression-oriented programming

3.3. Functions

3.3.1. Functions in object-oriented programming languages

3.3.2. Functions as first-class values

3.3.3. Moving behaviour around

3.3.4. Composing functions

3.3.5. The size of functions

3.4. Manipulating immutable collections

3.4.1. Transformations instead of loops

3.4.2. Higher-order functions for manipulating collections

3.5. Making the switch to a declarative programming style

3.5.1. Never use the get method on an Option

3.5.2. Only use immutable values and data structures

3.5.3. Aim for small and crisp functions

3.5.4. Iterate and refine your functional style

3.6. Summary

4. Quick introduction to Play

4.1. Play application structure and configuration

4.1.1. Introducing the Simple Vocabulary Teacher

4.1.2. Creating a minimal Play application scaffold

4.1.3. Building the project

4.2. Request handling

4.2.1. The request lifecycle

4.2.2. Request routing

4.2.3. Controllers, Actions and Results

4.2.4. WebSockets

4.2.5. Altering the default request handling pipeline

4.3. Summary

Part Two

5. Futures

5.1. Working with Futures

5.1.1. Future fundamentals

5.1.2. Futures in Play

5.1.3. Testing Futures

5.2. Designing asynchronous business logic with Futures

5.2.1. Identifying parallelizable elements

5.2.2. Composing Futures

5.2.3. Propagating and handling errors

5.3. Summary

6. Actors

6.1. Actor fundamentals

6.1.1. The Simple Twitter Analytics service

6.1.2. Laying out the foundation: actors and their children

6.2. Letting it crash - supervision and recovery

6.2.1. Robust storage

6.2.2. Letting it crash

6.2.3. Watching actors die and reviving them

6.3. Reacting to load - patterns for monitoring and preventing service overload

6.3.1. Control-flow messages

6.3.2. Prioritizing messages

6.3.3. Circuit breakers

6.4. Summary

7. Dealing with State

7.1. Working with state in a stateless Play web-application

7.1.1. Databases

7.1.2. Client-side state using the Play session

7.1.3. Server-side state using a distributed cache

7.2. Command Query Responsibility Segregation and Event Sourcing

7.2.1. The Twitter SMS Service

7.2.2. Setting up the SMS gateway

7.2.3. Writing the event stream with persistent actors

7.2.4. Configuring Akka Persistence to write to MongoDB

7.2.5. Handling an incoming command: subscribing to user mentions

7.2.6. Transforming the event stream into a relational model

7.2.7. Querying the relational model

7.2.8. A word on eventual consistency

7.3. Summary

8. Responsive User Interfaces

8.1. Integrating Scala.js and Play

8.1.1. The application structure

8.1.2. Setting up the build process

8.1.3. Creating a simple Scala.js application

8.2. Integrating Scala.js and AngularJS

8.2.1. Setting up AngularJS bindings

8.2.2. Creating the AngularJS application

8.2.3. Initializing the AngularJS dashboard module and its dependencies

8.2.4. Initializing the Dashboard controller

8.2.5. Creating the partial view

8.2.6. Loading the AngularJS application in HTML

8.3. Integrating existing JavaScript libraries with Scala.js

8.3.1. Wrapping an existing JavaScript library as an AngularJS service

8.3.2. Creating a service to fetch data for a graph

8.3.3. Displaying metrics using the Chart.js library

8.4. Client-side failure

8.4.1. Preventing bugs with tests

8.4.2. Detecting WebSocket connection failure

8.4.3. Notifying users

8.4.4. Monitoring client-side errors

8.5. Summary

Part Three

9. Reactive Streams

9.1. Why Reactive Streams

9.1.1. Streaming with non-blocking back pressure

9.1.2. Manipulating asynchronous streams

9.2. Introducing Akka Streams

9.2.1. Core principles

9.2.2. Manipulating Streaming Tweets

9.3. Summary

10. Deploying Play applications

10.1. Preparing a Play application for production

10.1.1. Creating a simple application to deploy

10.1.2. Writing and running integration tests with Selenium

10.1.3. Preparing the application for production

10.2. Setting up continuous integration

10.2.1. Running Jenkins via Docker

10.2.2. Configuring Jenkins to build our application

10.3. Deploying the application

10.3.1. Deployment on Clever Cloud

10.3.2. Deployment on your own server

10.3.3. Which deployment model to use

10.4. Summary

11. Testing Reactive Web Applications

11.1. Testing Reactive Traits

11.1.1. Testing responsiveness

11.1.2. Testing resilience

11.1.3. Testing elasticity

11.1.4. Where to test?

11.2. Testing individual reactive components

11.2.1. Testing individual components for responsiveness

11.2.2. Testing indvidual components for resilience

11.3. Testing the entire reactive application

11.3.1. Creating a simple application to generate random numbers

11.3.2. Testing for resilience with Gatling

11.3.3. Testing for scalability with Bees with Machine Guns

11.4. Summary


Appendix A: Installing the Play Framework

A.1. Downloading and installing Play

A.2. Setting up the environment on Linux or Mac OS X

A.3. Setting up the environment on Windows

What's inside

  • Reactive application architecture
  • Basics of Play and Akka
  • Examples in Scala
  • Functional and asynchronous programming

About the reader

For readers comfortable programming with a higher-level language such as Java or C#, and who can read Scala code. No experience with Play or Akka needed.

About the author

Manuel Bernhardt is a passionate engineer, author, and speaker. As a consultant, he guides companies through the technological and organizational transformation to distributed computing.

placing your order...

Don't refresh or navigate away from the page.
print book $33.74 $44.99 pBook + eBook + liveBook
Additional shipping charges may apply
Reactive Web Applications (print book) added to cart
continue shopping
go to cart

eBook $26.99 $35.99 3 formats + liveBook
Reactive Web Applications (eBook) added to cart
continue shopping
go to cart

Prices displayed in rupees will be charged in USD when you check out.
customers also reading

This book 1-hop 2-hops 3-hops

FREE domestic shipping on three or more pBooks