These are my personal notes about Reactive Web Applications by Manuel Bernhardt – It was written in 2016 it is a bit dated already as it covers Play Framework 2.4 and it is currently at 2.8 some of the things in play have changed. Play and everything in Scala world is changing so quickly all books are outdated the day they are published but they are still useful.
This book contains a lot of good general information about how Play Framework works.
One problem is certain things have either been removed from play framework code API and no one bothered to leave a link in the API docs, or the code was wrong. In particular chapter 5
The compiler complains Execution does not exist.
The book is still full of great information and examples that give you a good idea of why you should do things a certain way and even examples of things to avoid.
But these are my notes for me.
Good coverage of how Plays ExecutionContext works in Chapter 5 starting on page 110 in particular. This chapter covers Futures, how to use them in Play and how the Execution context works. It covers how to create custom execution contexts for such things as DB access or for each service of a larger app.intensly
Chapter 5 page 11 covers Async Controller Actions, how to create them and why, lots of good info on pages 110 – 111.
Chapter 5 page 112 Covers Custom Error handlers, very useful information here, for handling errors when working with Futures.
Chapter 5 page 114 covers correctly configuring and using an ExecutionContext. It covers when and why you would want to do so. Page 115 & 116 carries on and goes into deeper coverage with Specialized Execution contexts such as DB heavy code. Pages 117 & 118 continue to cover Execution context in depth This is the best coverage of Play Frameworks Execution context I have found anywhere yet.
Page 119 & 120 covers testing futures a little
Page 120 section 5.2 talks about Designing Asynchronous business logic with Futures and identifying parallelizable elements.
Pages 121 through 128 continue to cover using Futures, the quirks associated with them and how to avoid them.
Page 123 mentions the reason Futures are better than callbacks is because futures can be composed or combined, this can make swapping things out quicker.
page 126 makes an interesting point about Futures and the order in which you declare them. This mentions a gotcha with a good example of something that wouldn’t work the way you expect it to with Futures.
Page 128 – 132 covers Handling errors when using futures.
Chapter 6 is a quick introduction to Akka Actors and how to use them in play apps.
Page 144 lists the actor methods such as tell, forward etc. and gives brief coverage.
Page 147 makes a point about using var over val for actors to make them immutable.
Pages 148 and 149 cover common beginner mistakes with actors and how to avoid them.
Page 149 quickly covers when to use an Actor vs Future, very good and useful insight here.
Page 154 Section 6.2.3 has good information about letting actors die and reviving them and other error/exception recovery information.
The rest of chapter 6 pages 155+ deal with monitoring and preventing actor service overload, circuit breakers and more on handing errors.
Page 157 – 158 address avoiding duplicate actions
Page 159 covers Actor Message priority as a way to keep an actor system from overlaoding.