title: Creating an actorpublisher and actorsubscriber with same actor
body: <p>I'm a newbie to akka streams. I'm using kafka as a source(using ReactiveKafka library) and do some processing of data through the flow and using a subscriber(EsHandler) as sink.</p>
  
  <p>Now I need to handle errors and push it to different kafka queue through an error handler. I'm trying to use EsHandler both as publisher and subscriber. I'm not sure how to include EsHandler as an middle man instead of sink.</p>
  
  <p>This is my code: </p>
  
  <pre><code>val publisher = Kafka.kafka.consume(topic, "es", new StringDecoder())
  
  val flow = Flow[String].map { elem =&gt; JsonConverter.convert(elem.toString()) }
  
  val sink = Sink.actorSubscriber[GenModel](Props(classOf[EsHandler]))
  
  Source(publisher).via(flow).to(sink).run()
  
  
  class EsHandler extends ActorSubscriber with ActorPublisher[Model] {
  
    val requestStrategy = WatermarkRequestStrategy(100)
  
    def receive = {
      case OnNext(msg: Model) =&gt;
        context.actorOf(Props(classOf[EsStorage], self)) ! msg
  
      case OnError(err: Exception) =&gt;
        context.stop(self)
  
      case OnComplete =&gt;
        context.stop(self)
  
      case Response(msg) =&gt;
        if (msg.isError()) onNext(msg.getContent())
    }
  }
  
  class ErrorHandler extends ActorSubscriber {
  
    val requestStrategy = WatermarkRequestStrategy(100)
  
    def receive = {
      case OnNext(msg: Model) =&gt;
        println(msg)
    }
  }
  </code></pre>