지속적인 이벤트 목록을 가져 와서 응답 (Action.async
)으로 보내려고합니다. 그러나 PersistenceQuery
개의 결과를 Future
개체로 변환 할 수 없습니다. 여기에 내가 runFold
내에서 인쇄물을 볼 수 있어요 코드Play framework, Akka Persistence, PersistenceQuery, Action.async의 Future Object로 소스를 변환 할 수 없습니다.
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
이지만, finalResult
는 반환되지 않았다. 나는 심지어 Await
에 노력했다, 심지어 분 동안 기다리고 난 후에, 결코 돌아 오지 않았다. 이 finalResult
은 응답으로 응답을 보내려는 모든 사용자 활동을 Action.async
으로 표시합니다. 나에게이 문제에 대한 Source
객체 Future
에
고마워요! 이것은 문서에서 강조 표시되어야합니다. – Ikrom