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);
}

}









share|improve this question




























    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);
    }

    }









    share|improve this question


























      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);
      }

      }









      share|improve this question















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 15 hours ago

























      asked 15 hours ago









      Aunmag

      4615




      4615





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          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






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Costa Masnaga

          Fotorealismo

          Sidney Franklin