title: Actor retry with back-off and retry limit
body: <p>I need retry mechanism on akka actors with increasing time between the retries and maximum retry limit.
  For this purpose I'm trying to use the BackOffSupervisor pattern, provided by akka. The problem is that, from my test, the back-off strategy and the retry limit seems to not work. Or maybe the problem is in the test?</p>
  
  <p>The test looks like this:</p>
  
  <p>A simple actor that throws exception at the first 5 messages</p>
  
  <pre><code>class SomeActor extends AbstractActor {
  
  private static int messageCounter = 0;
  
  //return the message to sender
  @Override
  public void preRestart(final Throwable reason, final Optional&lt;Object&gt; message) {
      getSelf().tell(message.get(), getSender());
  }
  
  
  @Override
  public Receive createReceive() {
      return receiveBuilder()
              .matchEquals("hello", message -&gt; {
                  messageCounter++;
                  getSender().tell("response", getSelf());
  
                  //Throw Exception at the first 5 messages
                  if (messageCounter &lt; 5) {
                      throw new Exception();
                  }
  
              })
              .build();
  }
  </code></pre>
  
  <p>}</p>
  
  <p>The BackOffSupervisor configuration</p>
  
  <pre><code>private ActorRef createSupervisedActor(Class&lt;? extends Actor&gt; actorClass) {
      final Props someActorProps = Props.create(actorClass);
  
      final Props supervisorProps = BackoffSupervisor.props(
              Backoff.onStop(
                      someActorProps, //actor to be supervised
                      "someActor",
                      Duration.ofSeconds(10), //min back-off time
                      Duration.ofMinutes(2), // max back-off time
                      0.2, // back-off increase factor
                      10) // max retry limit
                      .withSupervisorStrategy(
                              new OneForOneStrategy(
                                      DeciderBuilder
                                              .match(Exception.class, e -&gt; SupervisorStrategy.restart())
                                              .matchAny(o -&gt; SupervisorStrategy.escalate())
                                              .build())
                      )
      );
  
      return testSystem.actorOf(supervisorProps);
  
  }
  </code></pre>
  
  <p>And the test method</p>
  
  <pre><code>    @Test
  public void test() {
      new TestKit(testSystem) {{
          ActorRef actorRef = createSupervisedActor(SomeActor.class);
  
          actorRef.tell("hello", getRef());
  
          //Expect 5 responses in 1 second
          receiveN(5, Duration.ofSeconds(1));
      }};
  
  }
  </code></pre>
  
  <p>The test finishes way too fast. In under a second, when from the configuration of the BackoffSupervisor, I'm expecting to take at least a 50+ sec. </p>