0

我目前正在尝试将 MSF4J 与 StreamingOutput API 一起使用。但是,我不想流式传输文件,而是流式传输一系列无休止的短字符串/文本。我希望立即将字符串刷新到客户端。但是,客户端在刷新后没有得到它。我相信这是由于默认的 8kb 缓冲区,因为我的字符串会在一段时间后以块的形式刷新。如何像在 glassfish 中一样覆盖这个默认缓冲区?https://jersey.java.net/apidocs/2.22/jersey/org/glassfish/jersey/server/ServerProperties.html#OUTBOUND_CONTENT_LENGTH_BUFFER

我想要类似的东西...

Properties properties = new Properties()
properties.set("jersey.config.server.contentLength.buffer", 0);**

new MicroservicesRunner()
  .setProperties(properties)**
  .addInterceptor(new HTTPMonitoringInterceptor())
  .deploy(new MyService())
  .start();

我的直播课

new StreamingOutput(){    
     public void write(OutputStream os) throws IOException, WebApplicationException      {
        while(true){
           os.write("some string".getBytes());
           os.flush();
        }    
      }
}

谢谢你。

4

0 回答 0