0

I am using akka BackOff supervision with my actor. Whenever my actor receive the message, I am getting akka dead letter msg. Followings are my logs:

[INFO] - [2016-09-16 12:18:53,843] - [akka.actor.LocalActorRef] Message [com.zillion.notification.actors.MyActor$FirebaseRequestLog] from Actor[akka://default/deadLetters] to Actor[akka://default/user/$d/myActorRef#-1537227666] was not delivered. [1] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
[INFO] - [2016-09-16 12:18:53,843] - [akka.actor.LocalActorRef] Message [com.zillion.notification.actors.MyActor$FirebaseRequestLog] from Actor[akka://default/deadLetters] to Actor[akka://default/user/$d/myActorRef#-1537227666] was not delivered. [2] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
[INFO] - [2016-09-16 12:18:53,844] - [akka.actor.LocalActorRef] Message [com.zillion.notification.actors.MyActor$FirebaseRequestLog] from Actor[akka://default/deadLetters] to Actor[akka://default/user/$d/myActorRef#-1537227666] was not delivered. [3] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
[INFO] - [2016-09-16 12:18:53,844] - [akka.actor.LocalActorRef] Message [com.zillion.notification.actors.MyActor$FirebaseRequestLog] from Actor[akka://default/deadLetters] to Actor[akka://default/user/$d/myActorRef#-1537227666] was not delivered. [4] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
[INFO] - [2016-09-16 12:18:53,844] - [akka.actor.LocalActorRef] Message [com.zillion.notification.actors.MyActor$FirebaseRequestLog] from Actor[akka://default/deadLetters] to Actor[akka://default/user/$d/myActorRef#-1537227666] was not delivered. [5] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
[INFO] - [2016-09-16 12:18:53,850] - [akka.actor.LocalActorRef] Message [com.zillion.notification.actors.MyActor$FirebaseRequestLog] from Actor[akka://default/deadLetters] to Actor[akka://default/user/$d/myActorRef#-1537227666] was not delivered. [6] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.

Following is my BackOff Supervisor code:

Props backOffProps = BackoffSupervisor.props(
                Backoff.onFailure(
                        MyActor.props(eventLoggerService),
                        MyActor.BEAN_NAME,
                        Duration.create(3, TimeUnit.SECONDS),
                        Duration.create(1, TimeUnit.MINUTES),
                        0.20
                )
                .withAutoReset(FiniteDuration.apply(10, TimeUnit.SECONDS))
                .withSupervisorStrategy( new OneForOneStrategy(false,
                        match(DatabaseOperationException.class, ex -> {
                            if(ex.getCause() instanceof MongoTimeoutException){
                                return SupervisorStrategy.restart();
                            }else {
                                return SupervisorStrategy.resume();
                            }
                        })
                        .match(Throwable.class, e ->
                                SupervisorStrategy.restart()
                         ).build())
                    ));

        ActorRef backOffActorRef = system.actorOf(backOffProps);
        CompletionStage<Object> myActorFuture = ask(backOffActorRef, BackoffSupervisor.getCurrentChild(),
                Timeout.apply(50, TimeUnit.MILLISECONDS));
        return ((CurrentChild) eventFuture.toCompletableFuture().get(60, TimeUnit.MILLISECONDS)).ref().get();

How the backoff works and how can I resolve above problem?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Harmeet Singh Taara
  • 6,483
  • 20
  • 73
  • 126
  • The message ends up in the dead letter queue when the underlying actor that the supervisor protects is exceptioning out and the backoff is taking place – Cal Sep 16 '16 at 13:12
  • how could i solve that problem ? – Harmeet Singh Taara Sep 17 '16 at 09:00
  • 1
    So if you don't want to lose the messages, you will need to build something custom. Build an actor (let's call him intermediate) that holds onto those important messages. The child of the intermediate actor is your original actor. The intermediate actor will accept messages from the outside world and hold onto them. Then it will send messages to the child (which can possibly die). The end result is that you have a system that doesn't lose messages if an exception occurs in the child as the intermediate holds onto it. You would need to send acks to clear out messages held by the intermediate. – Cal Sep 17 '16 at 19:57
  • @Cal what are the benefits of `BackoffSupervisor` if our messages are lost ? – Harmeet Singh Taara Sep 20 '16 at 05:35
  • The purpose of the Backoff supervisor is to provide some breathing room for actors that deal with external dependencies that might exception out. So to give those external dependencies some time to recover. You could think of it as a circuit breaker for actors in a way. – Cal Sep 20 '16 at 21:27

0 Answers0