Play Framework: Incomplete chunked result
up vote
0
down vote
favorite
The problem is when I return chunked response following documentation with a number of random lines, not all of these lines appear in browser (Google Chrome, Postman). E.g. if I send 8192 lines the browser will show only ~7k or even ~4k. My goal is to generate large CSV file using this kind of approach.
public Result test() {
var source = Source.<ByteString>actorRef(256, OverflowStrategy.dropNew())
.mapMaterializedValue(actor -> {
new Thread(new MyRunnable(actor)).start();
return NotUsed.getInstance();
});
return ok().chunked(source);
}
// ------
public class MyRunnable implements Runnable {
private final ActorRef actor;
public MyRunnable(ActorRef actor) {
this.actor = actor;
}
public void run() {
for (var i = 0; i < 1024 * 8; i++) {
var line = String.format("%d %sn", i + 1, Utils.generateRandomString(64));
actor.tell(ByteString.fromString(line), null);
}
actor.tell(new Status.Success(NotUsed.getInstance()), null);
}
}
java playframework akka playframework-2.6
add a comment |
up vote
0
down vote
favorite
The problem is when I return chunked response following documentation with a number of random lines, not all of these lines appear in browser (Google Chrome, Postman). E.g. if I send 8192 lines the browser will show only ~7k or even ~4k. My goal is to generate large CSV file using this kind of approach.
public Result test() {
var source = Source.<ByteString>actorRef(256, OverflowStrategy.dropNew())
.mapMaterializedValue(actor -> {
new Thread(new MyRunnable(actor)).start();
return NotUsed.getInstance();
});
return ok().chunked(source);
}
// ------
public class MyRunnable implements Runnable {
private final ActorRef actor;
public MyRunnable(ActorRef actor) {
this.actor = actor;
}
public void run() {
for (var i = 0; i < 1024 * 8; i++) {
var line = String.format("%d %sn", i + 1, Utils.generateRandomString(64));
actor.tell(ByteString.fromString(line), null);
}
actor.tell(new Status.Success(NotUsed.getInstance()), null);
}
}
java playframework akka playframework-2.6
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
The problem is when I return chunked response following documentation with a number of random lines, not all of these lines appear in browser (Google Chrome, Postman). E.g. if I send 8192 lines the browser will show only ~7k or even ~4k. My goal is to generate large CSV file using this kind of approach.
public Result test() {
var source = Source.<ByteString>actorRef(256, OverflowStrategy.dropNew())
.mapMaterializedValue(actor -> {
new Thread(new MyRunnable(actor)).start();
return NotUsed.getInstance();
});
return ok().chunked(source);
}
// ------
public class MyRunnable implements Runnable {
private final ActorRef actor;
public MyRunnable(ActorRef actor) {
this.actor = actor;
}
public void run() {
for (var i = 0; i < 1024 * 8; i++) {
var line = String.format("%d %sn", i + 1, Utils.generateRandomString(64));
actor.tell(ByteString.fromString(line), null);
}
actor.tell(new Status.Success(NotUsed.getInstance()), null);
}
}
java playframework akka playframework-2.6
The problem is when I return chunked response following documentation with a number of random lines, not all of these lines appear in browser (Google Chrome, Postman). E.g. if I send 8192 lines the browser will show only ~7k or even ~4k. My goal is to generate large CSV file using this kind of approach.
public Result test() {
var source = Source.<ByteString>actorRef(256, OverflowStrategy.dropNew())
.mapMaterializedValue(actor -> {
new Thread(new MyRunnable(actor)).start();
return NotUsed.getInstance();
});
return ok().chunked(source);
}
// ------
public class MyRunnable implements Runnable {
private final ActorRef actor;
public MyRunnable(ActorRef actor) {
this.actor = actor;
}
public void run() {
for (var i = 0; i < 1024 * 8; i++) {
var line = String.format("%d %sn", i + 1, Utils.generateRandomString(64));
actor.tell(ByteString.fromString(line), null);
}
actor.tell(new Status.Success(NotUsed.getInstance()), null);
}
}
java playframework akka playframework-2.6
java playframework akka playframework-2.6
edited 15 hours ago
asked 15 hours ago
Aunmag
4615
4615
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53349354%2fplay-framework-incomplete-chunked-result%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown