[英]Streaming a JSON document to a Rest web service with java
I've seen examples where you can use a http://docs.oracle.com/javaee/6/api/javax/ws/rs/core/StreamingOutput.html from a Rest api so that the restful respones can be a Json stream. 我看到了一些示例,您可以在其中使用来自Rest api的http://docs.oracle.com/javaee/6/api/javax/ws/rs/core/StreamingOutput.html ,以便宁静的响应可以是Json流。 This makes it so you can start processing JSON tokens as they come in instead of waiting until the whole thing is there.
这样一来,您就可以开始处理传入的JSON令牌,而不必等到整个事情都在那里。
Now i'm interested in the other way. 现在我对另一种方式感兴趣。
The flow: 流程:
Does such a feature exist? 是否存在这样的功能?
The only idea I have come up with is to have the client stream to a local file then send the server a URL to that file to stream from. 我想出的唯一想法是让客户端流到本地文件,然后向服务器发送指向该文件的URL。
maybe you can use java.nio(or Socket) to create a server and clients. 也许您可以使用java.nio(或Socket)创建服务器和客户端。
client read data and send the data(json?string?) to server one by one(or any other definite quantity) 客户端读取数据并将数据(json?string?)一一(或任何其他确定数量)发送到服务器
when the data received by server then server start to process it. 当服务器接收到数据时,服务器开始处理它。 and client continue to read remaining data and continue to send it to server.
并且客户端继续读取剩余数据,并继续将其发送到服务器。
here are some example: https://examples.javacodegeeks.com/core-java/nio/java-nio-socket-example/ 这是一些示例: https : //examples.javacodegeeks.com/core-java/nio/java-nio-socket-example/
my english is poor. 我的英文程度不高。 Is this what you want to know?
这是您想知道的吗? i wish it can help you.
希望它能对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.