Akka BackOff监督策略

时间:2016-09-16 07:02:35

标签: java akka akka-supervision

我正和我的演员一起使用akka BackOff监督。每当我的演员收到消息时,我都会收到akka死信msg。以下是我的日志:

[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'.

以下是我的BackOff主管代码:

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();

退避如何运作以及如何解决上述问题?

0 个答案:

没有答案