import akka.actor.Actor import akka.cluster.pubsub.DistributedPubSub import akka.cluster.pubsub.DistributedPubSubMediator.Subscribe import scala.reflect.runtime.universe._ /** Actor that can subscribe to the pipes */ trait Subscriber extends Actor { //PubSub for the current actor system private lazy val pubsub = DistributedPubSub(context.system).mediator /** * Subscribe for the given type of data * * @tparam A Type that you are interested in receiving */ protected def subscribe[A]()(implicit tag: TypeTag[A]): Unit = pubsub ! Subscribe(typeOf[A].getClass.getName, self) }