Behaviors

Actors in GoAkt have the power to switch their behaviors at any point in time. When you change the actor behavior, the new behavior will take effect for all subsequent messages until the behavior is changed again. The current message will continue processing with the existing behavior. You can use Stashing to reprocess the current message with the new behavior. See Stashing

To change the behavior, call the following methods on the ReceiveContext interface when handling a message:

  • Become - switches the current behavior of the actor to a new behavior.

  • UnBecome - resets the actor behavior to the default one which is the Actor.Receive method.

  • BecomeStacked - sets a new behavior to the actor to the top of the behavior stack, while maintaining the previous ones.

  • UnBecomeStacked() - sets the actor behavior to the previous behavior before BecomeStacked() was called. This only works with BecomeStacked().

Last updated