+ private ActorRef createShardManager(ActorSystem actorSystem, ShardManager.Builder builder, String shardDispatcher,
+ String shardManagerId){
+ Exception lastException = null;
+
+ for(int i=0;i<100;i++) {
+ try {
+ return actorSystem.actorOf(builder.props().withDispatcher(shardDispatcher).withMailbox(
+ ActorContext.MAILBOX), shardManagerId);
+ } catch (Exception e){
+ lastException = e;
+ Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+ LOG.debug(String.format("Could not create actor %s because of %s - waiting for sometime before retrying (retry count = %d)", shardManagerId, e.getMessage(), i));
+ }
+ }
+
+ throw new IllegalStateException("Failed to create Shard Manager", lastException);
+ }
+