如何仅以一次获得Jersey RESTful客户端连接的同时将Pojos列表(Jersey)列为输出流:
//creating client
client = ClientBuilder.newClient( new ClientConfig().register( LoggingFilter.class ) );
//creating stream
StreamingOutput outputStream = new StreamingOutput() {
@Override
public void write(OutputStream os) throws IOException,
WebApplicationException {
Writer writer = new BufferedWriter(new OutputStreamWriter(os));
listItem.parallelStream().forEach(item->{
try {
String str = mapper.writeValueAsString(item);
writer.write(str);
//writer.flush();
} catch (IOException e) {
e.printStackTrace();
}
});
}
};
client.target("http://localhost:8080/streamrepo/stream/check").request(MediaType.APPLICATION_OCTET_STREAM_VALUE).post(Entity.entity(outputStream, MediaType.APPLICATION_OCTET_STREAM_VALUE));
but logger saying content length is zero , although connection is established , basically I want to stream the result but want to get client connection only once .Is there any way to achieve such kind of things
但是我不想多次休息,我只想获得一次客户端连接,然后将listOrderDto作为输出流发布到客户端。
2018-07-21 13:47:37.916 INFO 30986 --- [nio-8080-exec-1] o.glassfish.jersey.filter.LoggingFilter : 1 * Client response received on thread http-nio-8080-exec-1
1 < 406
1 < Content-Length: 0
1 < Date: Sat, 21 Jul 2018 08:17:37 GMT