Book Image

Scala Reactive Programming

By : Rambabu Posa
Book Image

Scala Reactive Programming

By: Rambabu Posa

Overview of this book

Reactive programming is a scalable, fast way to build applications, and one that helps us write code that is concise, clear, and readable. It can be used for many purposes such as GUIs, robotics, music, and others, and is central to many concurrent systems. This book will be your guide to getting started with Reactive programming in Scala. You will begin with the fundamental concepts of Reactive programming and gradually move on to working with asynchronous data streams. You will then start building an application using Akka Actors and extend it using the Play framework. You will also learn about reactive stream specifications, event sourcing techniques, and different methods to integrate Akka Streams into the Play Framework. This book will also take you one step forward by showing you the advantages of the Lagom framework while working with reactive microservices. You will also learn to scale applications using multi-node clusters and test, secure, and deploy your microservices to the cloud. By the end of the book, you will have gained the knowledge to build robust and distributed systems with Scala and Akka.
Table of Contents (16 chapters)

When we execute actorRef.tell (message), what happens internally?

This section explains what happens under the hood to understand the things well. If you are not interested in knowing this, skip this section and move on to the next parts of this chapter.

On a high level, Actor Toolkit components perform the following steps:

  1. ActorRef makes a call to its !() function.
  2. ActorRef hands over the message to the dispatcher.
  3. Dispatcher enqueues the message into the mailbox.
  4. Dispatcher creates an executorService (Executor).
  5. Dispatcher creates a mailbox thread—mbox.
  6. Dispatcher makes a call to the execute() function of executorService:
  1. The executorService.execute() method invokes the mailbox's run() function: 
  1. Mailbox's run() function dequeues the message.
  2. Mailbox's run() function hands over that message to the...