Hi,
Currently my actor becomes ready when it receives a msg :
class MyActor {
private val mediator = DistributedPubSubExtension(context.system).mediator
mediator ! Subscribe(Subscriptions.Index, self)
...
override def receive = {
case SubscribeAck(Subscribe(Subscriptions.Index, None, self)) =>
context become ready
}
def ready =
createPart.receive orElse
retrievePart.receive
}
This creates problems in test cases, when I send a msg to my actor:
myActor ! Create(...) // this is received before SubscribeAck and hence it is ignored
My temp solution is to sleep a bit after creating an actor so that I give an opportunity to the mediator to send the SubscribeAck:
val indexActor = system.actorOf(Props(IndexActor.empty(IntKey, StringValue, cluster.ref)))
// TODO: replace this with something better. This is required so that the actor becomes ready
Thread.sleep(5)
Is there a better solution?
Thanks
#