I have recently ported some of my code to leverage akka framework and I
randomly come across errors where I think actor constructor is not
initialized completed.
I have this ActorFactory class which spins of supervisor actor, and in each
supervisor actor constructor i have code to spawn child actor as described
below.
class ActorFactory(factorybuilder:IFactoryBuilder) extends IActorFactory{
createActor[ConfigSupervisor](Props(new ConfigSupervisor(this)))
createActor[RabbitSupervisor](Props(new
RabbitSupervisor(this,ConfigReader.getRabbitConfig)))
createActor[DAOChiefSupervisor](Props(new
DAOChiefSupervisor(this,factorybuilder.daoFactory)))
}
class DAOChiefSupervisor(factory:IActorFactory,daofactory:IDAOFactory)
extends BaseSupervisor
{
val log = LoggerFactory.getLogger(this.getClass())
//Code to spin off child actor
val dao = factory.createChild[DAOSupervisor](this, Props(new
DAOSupervisor(factory,daofactory)))
}
trait IActorFactory {
val system = ActorSystem()
var actorMaps= TrieMap[String,IActorURI]()
val log = LoggerFactory.getLogger(this.getClass())
def createActor[A:TypeTag](instance:Props) : IActorURI =
{
val name = getName[A]
val newactor = ActorURI(system.actorOf(instance,name))
actorMaps += (name -> newactor)
log.info("Creating Actor " +name)
newactor
}
def createChild[A:TypeTag](parent:Actor, instance:Props) :IActorURI =
{
val name = getName[A]
val newactor = ActorURI(parent.context.actorOf(instance,name))
actorMaps += (name -> newactor)
log.info("Creating Child Actor " +name)
newactor
}
def getActor[A:TypeTag]() =
{
val name = getName[A]
val actor = actorMaps.get(name)
actor match
{
case None => log.error(f"Actor $name not found")
case _ =>
}
actor
}
So what I am seeing is when I try to access DAOSupervisor from different
lines of code it gives me error message saying Actor not found, so it looks
like Actor constructor is not fully initialized when i get reference back.
Thanks in advance for your help.
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.