Things that were important enough at the time when they were written.

Viktor Klang is a legendary programmer, known from places like the Internet. Consider following him on Twitter.

Posts tagged Akka

Mar 6

Implementing PostStart in #Akka

This question comes up every now and then, and my answer has since the first time, been refined, so I thought I’d give the answer here.

"How do I run some initialization logic in the thread of the dispatcher and not the creator of the actor?"

I present to you, PostStart:

If you can’t see the code, click here



Feb 25

This is exactly what I want Akka to solve

"The fact is that everyone has scalability issues, no one can deal with their service going from zero to a few million users without revisiting almost every aspect of their design and architecture."

Quoted from : http://37signals.com/svn/archives2/dont_scale_99999_uptime_is_for_walmart.php

Dec 28

All #Actors in #Scala - compared

As a late Christmas present I bring this to you dear readers:

I recently invited David Pollak (of Lift fame), Jason Zaugg (of Scalaz fame), Philipp Haller (of Scala Actors fame) and myself to collaborate on a feature matrix that would allow people to see the similarities and differences between the Actor libraries on the Scala platform.

So I’d like to start out by thanking David, Jason, Runar, Jonas, Philipp, Martin and all the people involved in these great projects for taking the time to fill out the matrix.

Here’s a link to a PDF-version of the document, enjoy!

PS. I attempted to embed the comparison to this blog post, but the formatting simply goes haywire. DS.

Dec 27

√iktor needs your help!

I’ve got some ideas for conference/group talks that I have yet to assemble, but I thought I’d let the community have a vote in what they’d think be interesting.

Proposal 1:

Git things done

Approx time: 45 minutes

"This is a case-study on moving from CVS/SVN to Git I did at a previous employer. It’s about the challenges faced - cultural problems, technical problems, process problems and touches areas like: Code reviews, agile&lean (Scrum/Kanban), pragmatisism and corporate politics."

Proposal 2:

The Kay Way - True Object Orientation

Approx time: 30 minutes

"This talk explores OO using Actors, a model of concurrency that encapsulates Alan Kays original concept of object-orientation, showing different models of composition and inheritance, message-passing, asynchronous and synchronous messaging using the Akka framework"

Proposal 3:

Faster, Harder, Actor

Approx time: 25 minutes

"At the very core of Akka lies the Executor-Based-Event-Driven-Dispatcher, or EBEDD as we call it for short. This talk goes through its design and how it manages to provide the best default for Akka Actors in terms of performance and reliability and what configuration is possible to tune it for your workloads."

Proposal 4:


Approx time: 20 minutes

"This talk is some tips and tricks to write Scala-code that can be easily consumed by Java code, with dos and don’ts and examples from Scala projects."

So what I need from you is to comment on this blog post what you’ find interesting of the above mentioned proposals, or if you have any other suggestions on what you’d like for me to present.

Thanks for helping me out!

Nov 29

Dispatchers in Akka 1.0-RC1

Curious about what we’ve done?

A lot of work has gone into the different dispatchers through Akkas relatively short but intense life so far.

Here are some news for Akka 1.0-RC1:

1) There is no public start/stop lifecycle anymore, the dispatcher will be started when it gets its first actor and will be stopped when the last actor leaves

2) The dispatchers will re-start when they get another actor if they were previously stopped

3) The dispatchers will only stop if a new actor hasn’t registered within X millis after the last one leaves. This timeout is tunable by default in your akka.conf: “akka.actor.dispatcher-shutdown-timeout”

4) All dispatchers now share the same unit test, this means that can ensure they have the same behavior i.e. respecting the Actor Model.

5) Since Dispatchers can be restarted you never need to worry about when and how to stop your dispatchers, and how to handle re-initialization.

We have also removed the Reactor based Dispatchers since they had lousy performance and were never used.

Some more good news is that we have managed to improve the performance even further, with ExecutorBasedEventDrivenDispatcher closing in on the HawtDispatchers excellent non-blocking performance.

Happy hAkking!

The Future is dead?

No! Long live the Future!

Something that’s new in Akka 1.0-RC1 is the possibility to add hooks that are executed when a Future is completed.


Welcome to Scala version 2.8.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_22).
Type in expressions to have them evaluated.
Type :help for more information.

scala> import akka.actor._
import akka.actor._

scala> import akka.actor.Actor._
import akka.actor.Actor._

scala> val actor = actorOf( new Actor {
  def receive = {
    case “foo” => Thread.sleep(10000); /*Simulate blocking*/

scala> (actor.!!![String](“foo”)) onComplete {
  f => println(
         if (f.result.isDefined)
           “Got result: ” + f.result.get
           “Got exception: ” + f.exception.get

11:55:33.762 [akka:event-driven:dispatcher:global-3] DEBUG akka.dispatch.MonitorableThread - Created thread akka:event-driven:dispatcher:global-3
res8: akka.dispatch.Future[String] = akka.dispatch.DefaultCompletableFuture@422f3d17

scala> Got result: bar

This also enables non-busy-waiting Futures.awaitAll, Futures.awaitOne and Futures.awaitEither!

Happy hAkking!

Nov 28

When you don’t handle it

Something that’s new in Akka 1.0-RC1 is the “unhandled”-callback for Actor.

This is what it looks like:

    * User overridable callback.
    * Is called when a message isn’t handled by the current behavior of the actor
    * by default it throws an UnhandledMessageException
    def unhandled(msg: Any){
      throw new UnhandledMessageException(msg,self)

Then the current behavior of an actor doesn’t handle a message, we pass that message to the unhandled method, and by default that throws an UnhandledMessageException with the affected actor and the message that wasn’t handled. This exception doesn’t have a stacktrace (so it’s rather efficient to create).

However, this gives you an excellent opportunity to override this behavior, if you want to have DLQ or you simply want to log the unhandled message.


Nov 27

The self matters

What’s new in Akka 1.0-RC1 is that HotSwap now takes the following signature:

case class HotSwap(code: ActorRef => Actor.Receive, discardOld: Boolean = true)

Before it only had:

case class HotSwap(code: Actor.Receive)

So what’s new is that you can use the “discardOld” parameter to control if you want behaviors to be stacked or not. “discardOld = true” will essentially issue an “unbecome” before it applies the new code.

The problem with HotSwap before was that you couldn’t have any reference to “self”, and that became a major pain in the rear, so we changed the signature to be a function from ActorRef to Receive, and the parameter passed to that function will be “self”.

So now you can do:

val newBehavior = (self:ActorRef) => {

  case msg => self.reply(“Service temporarily unavailable”)

}: Receive

and send it to any actor:

actorRef ! HotSwap(newBehavior)

Happy hAkking!

Oct 21

Akka 1.0-M1 is out!!


We, the Akka committers, are very proud to announce the release of Akka 1.0-M1,
the first of 2 milestone releases leading up to the final 1.0 release.

It is all thanks to a fantastic team [http://doc.akkasource.org/team]
and user community. Thank you all for your time, hard work and great contributions.

The full release notes can be seen here: [http://doc.akkasource.org/release-notes].

91 tickets have been handled since the release of 0.10, and they can be seen here:

Download it here: [http://github.com/jboner/akka/downloads].

Updated Maven repository here: [http://www.scalablesolutions.se/akka/repository/].

Here’s the documentation: [http://doc.akkasource.org]

Here’s the highlights on what’s happened since 0.10!

- Java API on par with the Scala API
- Say less, do more! Boilerplate reduction surgery performed.
- New persistence backends: Voldemort, HBase, Riak and CouchDB!
- Fewer deps for using actors only: akka-core is split into akka-actor, akka-remote and akka-typed-actor
- Lower memory footprint gives you 25% more actors on the same hardware
- ThreadBasedDispatcher can deallocate its thread when idling
- Lots of tweaks and bugfixes


Page 1 of 2