I am trying to get list of persistent events and send it as response(
Action.async). But I am not able to convert PersistenceQuery results to 
Future object. Here is the code

val queries = 
PersistenceQuery(actorSystem).readJournalFor[CassandraReadJournal](CassandraReadJournal.Identifier)
val source: Source[EventEnvelope, NotUsed] = 
queries.eventsByPersistenceId("MYID", 0, Long.MaxValue)
val mappedSource: Source[JsValue, NotUsed] = source.mapAsync(1) { e =>
      e.event match {
        case l: String =>
           Future(Json.parse(l))
      }
   }
val finalResult: Future[List[JsValue]] = 
mappedSource.take(10).runFold(List[JsValue]())((a, b) => {
      println(a)
      a :+ b
    })
finalResult

I am able to see prints within runFold, but finalResult was never returned. 
I even tried to Await, even after waiting for minutes, it never returned. 
This finalResult shows all the user activity wanted to send it as response 
as Action.async. Please let me know what is the way to convert Source to 
Future object

-- 
>>>>>>>>>>      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 https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to