Skip to content

Instantly share code, notes, and snippets.

@miere
Created September 16, 2013 03:07
Show Gist options
  • Select an option

  • Save miere/6576335 to your computer and use it in GitHub Desktop.

Select an option

Save miere/6576335 to your computer and use it in GitHub Desktop.
Simple uAkka actor implementation used to demonstrate the basics with uAkka improved API.

uAkka basics

Actor System Auto Creation

Every time a WAR is deployed with uakka-servlet as dependency, an ActorSystem is created named with the WAR name.

Auto Handling Messages

Every time a message is consumed, HandleActor superclass will try to find a method named "handle" that accepts as parameter the same object type as the arrived message.

Actor Auto Creation

Every time an Actor is deployed with @Service annotation it will be auto-created in the WAR auto-created actor system.

Actor Injection

Every auto created actor could be injected with the same @Service annotation in a ActorRef field. Its possible to lookup the referenced actor by its name, or by its class.

import com.texoit.uakka.api.*
public class HelloActor extends HandledActor {
@Service( actor=WorldActor.class )
ActorRef worldActor;
// handle any String message
void handle( String message ) {
System.out.println( message );
}
// handle any SayHello instance message
void handle( SayHello sayHello ){
worldActor.tell( "Hello" );
}
}
import com.texoit.uakka.api.*
// it will auto-create the actor
@Service
public class WorldActor extends HandledActor {
String handle( String message ) {
System.out.println( message );
// auto replay
return "World";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment