Closed georgeOsdDev closed 11 years ago
@ngocdaothanh How can I detect new actor have been registered in glokka. I want ton know all of names who are registered. Is there any way which like akka's cluster member up event listener?
Please give a use case (scenario) where you want to detect new actor registration and to know all registered names.
Manager has client actor(s) and work as pubSub. And I register manager in glokka.
registry
├── manager1
│ ├── actor10
│ ├── actor11
│ :
│ └── actor1X
├── manager2
│ ├── actor2X
│ :
├── manager3
: ├── actor3X
: :
I want to use like below
class MessageQueManager extends Actor with Logger{
var clients = Seq[ActorRef]()
var managers = Seq[ActorRef]()
def receive{
case pub:Publish =>
clients.foreach{client =>
client ! MsgsFromQueue(pub.msg)
}
managers.foreach{manager
manager ! MsgsFromRegistry(pub.msg)
}
case msg:MsgsFromRegistry =>
clients.foreach{client =>
client ! MsgsFromQueue(pub.msg)
}
case sub: Subscribe =>
clients = clients :+ sender
val messages = LeoFS.readHead(sub.num)
sender ! MsgsFromQueue(messages)
//case new_registry: NewRegistry =>
// managers = managers :+ new_registry
}
}
So each manager have to know other manager's name or actorRef as new_registry
If glokka.Registry#doRegister
send message to all registerd actorRef
sender ! RegisterResultOk(name, actorRef)
// notice all items that register event happen
name2Ref.foreach{item =>
item._2 ! NewRegistry(name,actorRef)
}
Register manager as global.
https://github.com/ngocdaothanh/glokka