Just starting to learn Akka and really Scala as well...maybe not the smartest ordering of things.
I must be missing something very obvious, but I just can't seem to find it.
I'm trying to set the Actor's name when it is created, but the Info logging doesn't seem to be displaying it, instead using a system generated name:
[INFO] [11/14/2013 14:05:09.747] [BizRulesSystem-akka.actor.default-dispatcher-4] [akka://BizRulesSystem/user/$a] akka.actor.RepointableActorRef receiving message
[INFO] [11/14/2013 14:05:09.754] [BizRulesSystem-akka.actor.default-dispatcher-8] [akka://BizRulesSystem/user/$a/$a] akka.actor.LocalActorRef receiving message
[INFO] [11/14/2013 14:05:09.754] [BizRulesSystem-akka.actor.default-dispatcher-7] [akka://BizRulesSystem/user/$a/$b] akka.actor.LocalActorRef receiving message
[INFO] [11/14/2013 14:05:09.754] [BizRulesSystem-akka.actor.default-dispatcher-4] [akka://BizRulesSystem/user/$a/$c] akka.actor.LocalActorRef receiving message
[INFO] [11/14/2013 14:05:09.754] [BizRulesSystem-akka.actor.default-dispatcher-2] [akka://BizRulesSystem/user/$a/$e] akka.actor.LocalActorRef receiving message
[INFO] [11/14/2013 14:05:09.754] [BizRulesSystem-akka.actor.default-dispatcher-6] [akka://BizRulesSystem/user/$a/$f] akka.actor.LocalActorRef receiving message
[INFO] [11/14/2013 14:05:09.754] [BizRulesSystem-akka.actor.default-dispatcher-2] [akka://BizRulesSystem/user/$a/$g] akka.actor.LocalActorRef receiving message
[INFO] [11/14/2013 14:05:09.754] [BizRulesSystem-akka.actor.default-dispatcher-7] [akka://BizRulesSystem/user/$a/$d] akka.actor.LocalActorRef receiving message
Forgive the ugly, non-idiomatic Scala code below (remember, just learning here).
What is the proper way to name the runtime Actors, such that the logs look like:
[INFO] [11/14/2013 14:05:09.747] [BizRulesSystem-akka.actor.default-dispatcher-4] [akka://BizRulesSystem/user/SomeName] akka.actor.RepointableActorRef receiving message
[INFO] [11/14/2013 14:05:09.754] [BizRulesSystem-akka.actor.default-dispatcher-8] [akka://BizRulesSystem/user/SomeName/QualifierA] akka.actor.LocalActorRef receiving message
[INFO] [11/14/2013 14:05:09.754] [BizRulesSystem-akka.actor.default-dispatcher-7] [akka://BizRulesSystem/user/SomeName/QualifierB] akka.actor.LocalActorRef receiving message
[INFO] [11/14/2013 14:05:09.754] [BizRulesSystem-akka.actor.default-dispatcher-4] [akka://BizRulesSystem/user/SomeName/QualifierC] akka.actor.LocalActorRef receiving message
[INFO] [11/14/2013 14:05:09.754] [BizRulesSystem-akka.actor.default-dispatcher-2] [akka://BizRulesSystem/user/SomeName/QualifierD] akka.actor.LocalActorRef receiving message
[INFO] [11/14/2013 14:05:09.754] [BizRulesSystem-akka.actor.default-dispatcher-6] [akka://BizRulesSystem/user/SomeName/QualifierE] akka.actor.LocalActorRef receiving message
[INFO] [11/14/2013 14:05:09.754] [BizRulesSystem-akka.actor.default-dispatcher-2] [akka://BizRulesSystem/user/SomeName/QualifierF] akka.actor.LocalActorRef receiving message
[INFO] [11/14/2013 14:05:09.754] [BizRulesSystem-akka.actor.default-dispatcher-7] [akka://BizRulesSystem/user/SomeName/QualifierG] akka.actor.LocalActorRef receiving message
Qualifier.scala
trait Qualifier extends Actor with ActorLogging {
def name : String
def description: String
def qualifierList: Vector[String]
}
Includes.scala
class Includes(val name: String, val description: String, val qualifierList: Vector[String]) extends Qualifier {
def +> : Boolean = {
true
}
}
Excludes.scala
class Excludes(val name: String, val description: String, val qualifierList: Vector[String]) extends Qualifier {
def +>(): Boolean = {
true
}
}
BaseBusinessRule.scala
class BaseBusinessRule private (val qualifiers: Vector[BizQualifier], val approvedTx: Vector[Long], val deniedTx: Vector[Long])
extends BusinessRule {
def this(activityBusinessRuleName: String) = {
this(Vector.empty, Vector.empty, Vector.empty)
val qualSvc = new QualifierService
val includes = qualSvc.getIncludeQualifers(activityBusinessRuleName)
val excludes = qualSvc.getExcludeQualifiers(activityBusinessRuleName)
val qualifiers = includes ++ excludes
for (q <- qualifiers) {
if (q.isInstanceOf[Includes]) {
context.actorOf(Props(classOf[business_rules.actors.Includes],
q.name, q.description, q.qualifierList))
}
if (q.isInstanceOf[Excludes]) {
context.actorOf(Props(classOf[business_rules.actors.Excludes],
q.name, q.description, q.qualifierList))
}
}
}
'RunnerCode.scala'
object GreeterRunner extends App {
runGreeter()
def runGreeter() {
// there is a third 'root guardian' that the system and user
// guardians 'report' to
//implicit 'system guardian' of the entire actor system
val system = ActorSystem("BizRulesSystem")
// /user guardian actor
val bizRuleActor = system.actorOf(Props(classOf[BaseBusinessRule], "SomeName"))
bizRuleActor ! "test"
}
}
Thank you for any assistance.