How to handle "backoff" with notification?

Dear Akka users,

I have a supervisor actor S and child actor C (which is performing blocking operation).

I know that C can fail and I want to retry it every minute, therefore I should use:

final Props supervisorProps = BackoffSupervisor.props(
                Backoff.onFailure(
                  CActor.props(),
                  "c-actor",
                  FiniteDuration.create(50, TimeUnit.SECONDS),
                  FiniteDuration.create(70, TimeUnit.SECONDS),
                  0.2)
);

But the case is: if actor C fails, I want to start “BackupActor” B (which should be active only when C is not performing properly) so I should notify S about failure.

Therefore I should use

getContext().watch(cActor);

and listen for Terminated message by S (to start actor B).

Unfortunatelly in this approach Terminated is send only when actor C is stopped, not restarted by Backoff

What should I do?

How to use Backoff to restart C automatically, but also react and start/stop B on error/recover?

Kind regards

I think you have to implement that in your own actor instead of using BackoffSupervisor.

BackoffSupervisor is convenient, but it’s not difficult to implement similar thing in your own actor. Then you have full control of when there are failures from C.

Could you please point me to any examples/documentation on how to do it the “akka way” (I’m completly new to akka)?