Skip to content

Commit

Permalink
log when child actor is stopped
Browse files Browse the repository at this point in the history
Signed-off-by: Yannic Klem <yannic.klem@bosch.io>
  • Loading branch information
Yannic92 committed Aug 3, 2022
1 parent cce76fc commit 42365d5
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@

import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.OneForOneStrategy;
import akka.actor.PoisonPill;
import akka.actor.Props;
import akka.actor.ReceiveTimeout;
import akka.actor.Status;
import akka.actor.SupervisorStrategy;
import akka.actor.Terminated;
import akka.cluster.sharding.ShardRegion;
import akka.japi.pf.DeciderBuilder;
import akka.japi.pf.FI;
import akka.japi.pf.ReceiveBuilder;
import akka.pattern.AskTimeoutException;
Expand Down Expand Up @@ -105,6 +107,8 @@ public abstract class AbstractPersistenceSupervisor<E extends EntityId, S extend

protected final DittoDiagnosticLoggingAdapter log = DittoLoggerFactory.getDiagnosticLoggingAdapter(this);

private final SupervisorStrategy supervisorStrategy;

@Nullable protected final BlockedNamespaces blockedNamespaces;
@Nullable protected E entityId;
@Nullable protected ActorRef persistenceActorChild;
Expand Down Expand Up @@ -137,6 +141,13 @@ protected AbstractPersistenceSupervisor(@Nullable final ActorRef persistenceActo
this.defaultLocalAskTimeout = defaultLocalAskTimeout;
exponentialBackOffConfig = getExponentialBackOffConfig();
backOff = ExponentialBackOff.initial(exponentialBackOffConfig);
supervisorStrategy = new OneForOneStrategy(
DeciderBuilder
.matchAny(error -> {
log.error(error, "Got error in child. Stopping child actor for entityID <{}>.", entityId);
return SupervisorStrategy.stop();
}).build()
);
}

/**
Expand Down Expand Up @@ -245,7 +256,7 @@ protected CompletionStage<Object> modifyTargetActorCommandResponse(final Signal<
*/
@Override
public SupervisorStrategy supervisorStrategy() {
return SupervisorStrategy.stoppingStrategy();
return supervisorStrategy;
}

@Override
Expand Down Expand Up @@ -539,7 +550,8 @@ private void forwardDittoSudoToChildIfAvailable(final WithDittoHeaders withDitto
}
if (withDittoHeaders instanceof Signal<?> signal) {
signalTransformer.apply(signal)
.whenComplete((result, error) -> handleOptionalTransformationException(signal, error, sender))
.whenComplete(
(result, error) -> handleOptionalTransformationException(signal, error, sender))
.thenAccept(transformed -> persistenceActorChild.tell(transformed, sender));
} else {
persistenceActorChild.tell(withDittoHeaders, sender);
Expand Down

0 comments on commit 42365d5

Please sign in to comment.