Record all messages in Akka without changing all reception methods

I want to record all received messages to all participants of my Akka application. There is a config akka.actor.debug.receivethat will record all messages sent to the actor, if this method of receiving participants is LoggingReceive.

According to http://doc.akka.io/docs/akka/current/additional/faq.html this means that all receiving methods LoggingReceivemust be packaged, as in How to register all incoming messages from Akka (Java)

def receive = {
  LoggingReceive {
    case x ⇒ // do something
  }
}

Is there any way to do this implicitly or by config?

+4
source share
1 answer

, , - :

trait LoggingReceiveActor extends Actor{

  def receive = LoggingReceive(loggedReceive)

  def loggedReceive:Receive
}

class MyActor extends LoggingReceiveActor{

  def loggedReceive = {
    case _ => 
  }
}

, LoggingReceiveActor, impl loggingReceive, , , , .

+4

All Articles