3

I can get enumerator from mongodb, using reactivemongo like,

val enumerator = collection.find(rangeQuery)
       .cursor[State]
       .enumerate()

How to stream from this enumerator, using akka-http and akka-stream ?

I have converted the enumerator to publisher using, play streams experimental library,

Streams.enumeratorToPublisher(enumerator)

and stream from, akka-http like,

complete {

Source(publisher).map { a => /*Thread.sleep(100);*/ChunkStreamPart(a.asJson) }
HttpResponse(entity = HttpEntity.Chunked(MediaTypes.`application/json`, source))
}

But, the stream does not ending, the client is still waiting for the data. Is there any issue while creating enumerator ?. Or the issue in converting the Enumerator to publisher ?

I have already posted the question in reactivemongo google user group and play user group https://groups.google.com/forum/#!topic/reactivemongo/uObGXFQFH0Y

4

0 回答 0