title: Dynamically add/remove routees to a router actor
body: <p>Would you know a nice way in Akka/Scala to add/remove routees to a Broadcaster router?</p>
  
  <p>I have been looking at the Resizer - but does not meet my needs (I cannot see how to explicitly ask the resizer to resize (add routees) and to remove it seems that you need to send a Poison Pill to the actor which is then removed).</p>
  
  <p>So far, I have a router with a list of ActorRef and I send AddRoutee and RemoveRoutee messages....</p>
  
  <p><strong>My business case</strong>: I have an actor getting data from the network (via a proxy), and it needs to dispatch this data to independent actors for processing in parallel. Due to the graph nature of the recipients (DAG), the graph can evolve at runtime, vertices/edges being modified, hence the need to add and remove routees</p>
  
  <p>There must be a cleaner way to do this.</p>
  
  <p>Thanks for the pointers.</p>
  
  <p>Example of code I would like Akka to handle:</p>
  
  <pre><code> class MDActor extends Actor {
    @volatile var routees = Set[ActorRef]()
  
    def receive = {
      case ar: AddRoutee =&gt; routees = routees + ar.actorRef
      case rr: RemoveRoutee =&gt; routees = routees - rr.actorRef
      case msg =&gt; routees.foreach(r =&gt; r forward msg)
    }
  }
  </code></pre>