Hey, I’m wondering what is the correct way to work with async services (returns Future[OfResult]) inside Play background akka tasks. There is no information about it in play docs, It seems I can’t just return Future[TaskResult] at the end and get things done in a reactive way, so I’m using Await.result for each async service call. And even if I use my own custom execution context, sometimes I get weird exceptions from slick db layer and task stops working, this is not resilient at all (I would expect at least next schedule to work) so I think I’m doing it wrong.
The task is simple, I have an events table in database with some fields and date range, each day I’m checking if current date is inside date range, I remove passed events and activate new events. It requires me to:
- Get all events - which is list of Future[Event]
- Get through the list and modify or delete events
I’m doing it in procedural style with blocking Await.result
With small events count it fails very rare but with like thousands - it fails pretty soon (I assume because of limited database pool?)
It doesn’t look like just wrong database configuration because in regular async controller action everything works fine with huge amount of data so I suppose I’m doing it wrong