In a lot of old Akka examples you will see the following statements:
implicit val askTimeout = Timeout(1 second)
This will give error ‘object duration is not a member of package akka.util’. It turns out duration is now included in Scala standard library. To fix the error use the following import statement:
Check out the migration guide for other pieces of Akka functionality that have moved to Scala.
Just added custom application settings to Akka’s configuration file. Retrieving these settings is kind of a mission. This is the statement to retrieve a setting:
Hmmm, putting these statements everywhere in my code does not feel right, does it? Continue reading
Wanting to change the way logging information is logged I looked for the slf4j encoder pattern documentation. Why is it so hard to find? It turns out it was not the slf4j documentation I was looking for, but the logback documentation. Duh!
Anyway, it can be found here.
When adding to a Akka project I got the following error
java.lang.ClassNotFoundException: akka.event.slf4j.Slf4jLogger. I double checked my configuration and the Akka documentation. The documentation says the following:
Akka provides a logger for SL4FJ. This module is available in the ‘akka-slf4j.jar’. It has one single dependency; the slf4j-api jar. In runtime you also need a SLF4J backend, we recommend Logback.
No success. Continue reading
I have an actor setup where I have two consecutive routers. The first router is the parent of the second router. I wanted to move the configuration of these routers to the configuration file. Setting up the first router was not hard. The second one was a little tricker as the parent is different for each router. Continue reading
Akka makes use of HACON (Human-Optimized Config Object Notation) for configuration. Today I needed to check the config that was loaded. When printing the config to the terminal it is displayed in a compact format. I wanted to pretty print it so it was easier to read. I found a briljant blog post by marcinkubala.
I adapted a code snippet as follows: Continue reading
I was trying to use a Future in Akka today and got the following error message:
value ? is not a member of akka.actor.ActorRef
It turns out you have to import the akka.pattern.ask to use ‘?’. There is a implicit conversion from ActorRef to AskableActorRef.
So add the following import and you should be set to go (take note that ask does not start with a capital:
A quick note how to create a SBT project with the latest release of Akka.
Create a build.sbt file:
name := "ScalaAkkaTest"
organization := "&lt;Your organisation name&gt;"
version := "0.1.0-SNAPSHOT"
scalaVersion := "2.11.2"
resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.3.6"