I took a page out of the stream-integrations documentation, and hooked a 
simple ActorSubscriber up as a sink to a Flow. Something like:

class TestActorSubscriber extends ActorSubscriber {
  override def postStop() = {
    println("Stopped " + self.toString)
    super.postStop
  }
  override def preStart() = {
    println("Started " + self.toString)
    super.preStart
  }
  override protected def requestStrategy: RequestStrategy = // some stuff
  override def receive: Receive = {
    case OnNext(x) => // some stuff
  }
}

implicit val mat = ActorFlowMaterializer()
val runnableFlow = Source( () => io.Source.fromFile("foo.txt").getLines() 
).to(Sink.actorSubscriber(Props(new TestActorSubscriber())
runnableFlow.run()


Since the Sink takes a Props, and not an ActorRef, I assume the 
ActorSystemMaterializer is responsible for the lifecycle of that 
ActorSubscriber instance. When I run this flow, things work fine - the 
TestActorSubscriber is created (preStart fires), the messages stream 
through. 
However, the actor instance never stops once the iterator/Source completes. 
I can verify the OnComplete message gets to the TestActorSubscriber, but I 
never see the postStop fire.

Looking at the ActorSubscriber source, I see that it's designed to stop the 
actor if there's an attempt to create a subscription after an OnComplete is 
received. 
It doesn't look like anything happens in the normal case though, where the 
OnComplete/OnError is delivered *after* a subscription has already been 
established.

Is this just a bug? How is the lifecycle of ActorSubscriber/ActorPublisher 
instances managed?

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to