Записать поток данных в POST вызов chunk по chunk не работает

Как отправить POST (Jersey) список Pojos в качестве выходного потока при получении клиентского соединения Jersey RESTful только один раз:

     //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

0 ответов

Другие вопросы по тегам