Supervised behavior that will send a message to the parent when child is restarting

Is there a way to configure the supervising behavior for a child in akka-typed, in order for it to send a specific message to its parent everytime before the child is restarted?

Right now, we can supervise a child with a given Restart strategy using Behaviors.supervise, which returns a wrapped behavior for the child actor and handles its failures. Is there a way to wrapp the child with different supervising behavior that will send notification(message) to its parent before the child is restarted?

It could be a Java or Scala-based solution.

Thanks in advance.

The typed supervision strategy does not allow anything like that but you could potentially have the restarting actor react to the signal which is sent before it is restarted.

Note though that in general restarting is meant to be an internal detail of the actor somewhat opaque to the outside, ActorRefs keep working when an actor is restarted so needing to know that it restarted from the outside could indicate that it is worth taking a step back and reconsider the design.

Thanks for the response Johan. My goal is to provide better monitoring and observability in the parent actor, for example if the child is restarting every 5 mins, I would like to receive a notification that the system is unstable and something is indeed wrong.