title: How to subscribe actors into akka event bus automatically in Play2.4/Scala
body: <p>I am starting to dive into AKKA/Event Bus and related...</p>
  
  <p>I created a small test actor as follows:</p>
  
  <pre><code>class TestActor extends Actor with ClassLogger{
  
  
      @throws[Exception](classOf[Exception])
      override def preStart(): Unit = {
          context.system.eventStream.subscribe(context.self, classOf[FormFieldValue])
      }
  
      override def receive = {
          case (v: FormFieldValue) =&gt; logger.info("Value received: " + v.fieldValue)
          case _ =&gt; logger.info("Something unknown")
      }
  }
  </code></pre>
  
  <p>and trying to publish an event from another part of an application:</p>
  
  <pre><code>system.eventStream.publish(updatedValue)
  </code></pre>
  
  <p>Everything compiles and works as it used to, and nothing been logged. Basically, the actor is not been called. </p>
  
  <p>Now, I also tried to create a module that will register all the subscribers, like so:</p>
  
  <pre><code>class EventsRegistry @Inject()(system: ActorSystem) extends AbstractModule {
  
      override def configure(): Unit = {
          val testListeener = system.actorOf(Props(classOf[TestActor]))
  
          system.eventStream.subscribe(testListeener, classOf[FormFieldValue])
      }
  }
  </code></pre>
  
  <p>And configured the module in application.conf:</p>
  
  <pre><code>play.modules.enabled  += "events.modules.EventsRegistry"
  </code></pre>
  
  <p>and removed preStart from Actor.</p>
  
  <p>And now I am getting an error:</p>
  
  <blockquote>
    <p>lay.api.PlayException: No valid constructors[Module
    [events.modules.EventsRegistry] cannot be instantiated.]</p>
  </blockquote>
  
  <p>What am I doing wrong?</p>
  
  <p><strong>Update</strong>
  the only way I got that working is by setting up subscriber in Global#onStart:</p>
  
  <pre><code>override def onStart(app: play.api.Application) {
  
          val testListeener = Akka.system.actorOf(Props(classOf[TestActor]))
  
          Akka.system.eventStream.subscribe(testListeener, classOf[FormFieldValue])
  
      }
  </code></pre>
  
  <p>But usage of GlobalSettings is deprecated....</p>