0
StreamingOutputを使用して出力をストリームできることはわかっています。しかし、私はMessageBodyWriterでもそれを行うことができますか?私が次のように実装している場合:MessageBodyWriterからのストリーミング出力
@Override
public void writeTo(HelloWorldRepresentation t, Class<?> type, Type genericType, Annotation[] annotations,
MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
throws IOException, WebApplicationException {
"Hello world".chars().forEach(i -> {
try {
entityStream.write(i);
entityStream.write('\n');
entityStream.flush();
Thread.sleep(1000);
} catch (Exception e) {
throw new WebApplicationException(e);
}
});
}
すべての出力が同時に到着している(つまりストリーミングしていない)ようです。すべての手がかりは?
この問題を確認するhttps://stackoverflow.com/questions/41483716/chunkedinput-not-working-in-jersey – gladiator