来自 JAX-RS 客户端的确认
我向远程客户端公开一些 JAX-RS (Resteasy) Web 服务。
其中一个特别的服务是“告诉我自上次我问你以来的所有新闻”;在服务器上,我执行查询等操作,如果一切顺利,我会更新客户端上的一个属性,该属性告诉我未来的请求将从该日期开始。
这里的问题是,如果在返回答案时出现问题,我可能已经更新了“lastTime”属性,因此客户端可能会发现自己处于从未接收到部分数据的情况。
添加来自客户的某种“确认”的好方法是什么?告诉我它收到并正确处理了所有数据的东西......
I expose some JAX-RS (Resteasy) web services to a remote client.
One in particular is a service like "give me all news since the last time I asked you"; on the server I do my queries and all, and if everything went fine I update a property on the client which tells me future requests will start from that date.
The problem here is that if something goes wrong while returning the answer I could already have updated the "lastTime" property and so the client could find itself in the situation of never receiving part of the data.
What would be a good way of adding some kind of "acknowledge" from the client? Something that tells me that it received and correctly processd all the data...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你的概念是错误的:服务器应该是无状态的,而客户端应该知道他感兴趣的数据。
例如,客户端可以使用 If-Modified-Since header 获取标题中从日期开始的信息。如果服务器没有新的,它应该返回304(未修改)代码。
I think your concept is wrong: Server should be stateless, while client should know what data he is interested in.
For example the client can use If-Modified-Since header to get the information starting the date in the header. If server has no new, it should return 304 (Not Modified) code.