I have an akka actor that send messages to itself:
def receive = {
while (...) {
self ! "some message"
}
}
I want to use a Throttler to control the flow of messages that this actor sends to itself.
val throttler = system.actorOf(Props(new TimerBasedThrottler(15 msgsPer (1.minute))))
throttler ! SetTarget(Some(self))
and then change the while loop to send messages to throttler:
while (...) {
throttler ! "some message"
}
The problem is that I don't know how to access the "system" from inside the actor, to create the throttler. How to do this? Is there any better approach?