Reputation: 21300
In the Play Documentation Chunks are introduced as a solution to "streaming content". I am unsure whether streaming content can be produced slowly without blocking the HTTP thread or if I must separately make the convert the Chunks to an AsyncResult by changing (sc
is declared as Chunks
):
return ok(sc);
to:
return async(play.libs.Akka.future(new Callable<Result>() {
@Override
public Result call() throws Exception {
return ok(sc);
}
}));
When using the second solution, the chunks aren't appearing incrementally in the browser, and I wanted them to do that. Thanks in advance.
Upvotes: 0
Views: 478
Reputation: 11274
You only have to wrap your result in async
if your computation happens in a Promise
(Future
in 2.1), e.g. when using an Akka actor. The result type is then AsyncResult
.
Since Chunks
(defined in play.mvc.Results.java
) internally uses an Enumerator
that pushes the callback's content to an Iteratee
, it should be non-blocking.
Upvotes: 1