← Learning

Akka Module

NOTE

Akka is being phased out of our codebase. While you will need to use it from time to time in maintenance, most knowledge you need can be learned on the job. As such, this section is deprecated. You do not need to work through it as a new Scala dev, but it is left here as a resource for those who would like to dig deeper. It will not be updated moving forward.

What is Akka?

Akka is an open source toolkit that uses the actor pattern to manage concurrent, distributed systems on the JVM. With basis in concepts from Erlang, Akka provides fault tolerance and helps to remove state from concurrency, and has allowed us to build a scalable, reliable system that can crash and recover without need for excess babysitting. It also offers a wealth of configuration options to help us manage performance and behavior. This module will give you a brief walkthrough of the Akka docs, alongside a few projects to get you using the library. This module assumes completion of the Scala module, as it will be required to get through the projects presented here.

Getting Started: Pi Tutorial

Your first step will be going through the Getting Started guide, which will walk you through setting up Akka (and Scala, if you for some reason do not have it set up), and will help you set up a simple program to calculate Pi.

PLEASE NOTE: The tutorial has not been updated since scala 2.9.x. This is mostly not a problem, but dependency versioning has changed and some packages have been moved into the standard library, modifying what you will have to import. See here for information on what’s changed in the newest version. Your build.sbt might look like this instead:

name := "My Project"

version := "1.0"

scalaVersion := "2.10.4"

libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.3.5"

And your imports:

import akka.actor._
import akka.routing.RoundRobinRouter
import scala.concurrent.duration._

Akka Docs

Your next step will be reading through the Akka Docs. If you are a new developer, this may seem daunting- it’s important to get comfortable digging through docs to learn a library, however. This is a very common task in software development, and thankfully Akka’s documentation is quite good. You will only need to get from the beginning through the Scala API portion (obviously skipping the Java portion).

May the Future be with you

You will want to figure out what a Future is and how to use it.

Check your understanding with your mentor. Futures are often confusing and they can help clear up your understanding.