Hi everyone!
I am trying to create a stream with an ActorPublisher:
class SourceActor extends ActorPublisher[List[Int]] {
import akka.stream.actor.ActorPublisherMessage.Request
var list = List.range(1, 21).grouped(5).toList // for example
def receive = {
case Request(elems) => while (totalDemand > 0 && isActive) {
list match {
case Nil =>
onComplete()
self ! PoisonPill
case head :: tail =>
list = tail
onNext(head)
}
}
}
}
val sourceActor = system.actorOf(Props[SourceActor])
val source = Source(ActorPublisher[List[Int]](sourceActor))
val out = ForeachSink(println)
source.mapConcat{x => x}.runWith(out)
I expect to see numbers from 1 to 20, but random printed from 1 to 17~19
As I understand, it occur due to the stream complete before all elements
are processed. How can I implement an ActorPublisher properly and escape
this problem?
--
>>>>>>>>>> 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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.