Search code examples
akkamessagingactor

Does akka send own messages to custom actor by own initiative?


I'm creating some actor which should wrap all the incoming messages with its own message and forward them further. Unfortunately I don't have any common base class for user messages so I'm going to catch them with Object.class

Now I'm not sure if Akka can send its own messages to my Actor. I don't want to occasionally forward some system message which addressed to my wrapper actor.


Solution

  • Akka does internally send messages to your actors. These messages extend the internal SystemMessage trait. As the description in the source code states, system messages form their own queue in each actor's mailbox and are handled separately from other messages. We can trace the processing of these messages in Mailbox and ActorCell.

    When your forwarding actor receives a SystemMessage, that message is not wrapped and forwarded. Akka handles these messages internally, so your forwarding actor's behavior won't disrupt this system-level activity.