You should be able to do those calls immediately after each other, from same thread. ClusterSharding(context.system).start ClusterSharding(context.system).shardRegion
Start doesn't return until it has been initalized. Normally, I don't think these two things are done at the same place in the code, so I don't think it is much value in returning the ActorRef from start, but it would not hurt to do so. Please create a ticket<https://github.com/akka/akka/issues>. Thanks for reporting. Cheers, Patrik On Fri, May 9, 2014 at 3:48 PM, Jeroen Gordijn <[email protected]>wrote: > Hi, > > I followed the Advanced akka course in the last 2 days (which was awesome > by the way) and noticed something of the API which I think can be improved. > When you start the ClusterSharding its return type is Unit and you have to > retrieve the ShardRegion by calling the "shardRegion" on ClusterSharding. > However, this cannot take place in a short period, because > "shardRegion(...)" will 'throw new IllegalArgumentException(s"Shard type > [$typeName] must be started first")'. > > In my mind it would be an improvement if the start returns an ActorRef > immediately and then buffers all requests to it until the ShardRegion is > initialized. Am I overlooking some problems with that? > > Cheers, > Jeroen > > -- Start ShardRegion > ClusterSharding(context.system).start( > "player", > Some(Player.props), > Player.idExtractor, > Player.shardResolver(10) > ) > > -- get reference to ShardRegion > val playerRegion = ClusterSharding(context.system).shardRegion("player") > > -- > >>>>>>>>>> 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. > -- Patrik Nordwall Typesafe <http://typesafe.com/> - Reactive apps on the JVM Twitter: @patriknw JOIN US. REGISTER TODAY! <http://www.scaladays.org/> Scala <http://www.scaladays.org/> Days <http://www.scaladays.org/> June 16th-18th, <http://www.scaladays.org/> Berlin <http://www.scaladays.org/> -- >>>>>>>>>> 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.
