O'Reilly logo

Akka Essentials by Munish K. Gupta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Actor lifecycle monitoring

We saw the typed actor being defined and created, methods getting invoked, and how to stop the actors. In the case of untyped actors we saw support for the preStart() and postStop() methods where any resource initialization and subsequent cleaning could be handled.

So, in the case of typed actors, additional hooks can be implemented by making the implementation class implement additional interfaces. These interfaces can be overridden to initialize resources on actor start and clean up resources on actor stop.

Lifecycle callbacks

Typed actors can implement the TypedActor.PreStart and TypedActor.PostStop interfaces to add the additional hooks into the code.

Java:

public class Calculator implementsCalculatorInt, PreStart, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required