简体   繁体   English

如何与 Java 中的 RESTful 服务中的阻塞队列交互?

[英]How do I interact with a blocking queue in a RESTful service in Java?

Here's what I am trying to do:这是我想做的事情:

In a server-client system, the client sends some POST requests at a particular endpoint.在服务器-客户端系统中,客户端在特定端点发送一些 POST 请求。 The server(RestService) takes the request and puts it in an unbounded blocking queue.服务器(RestService)接受请求并将其放入无界阻塞队列中。 Another service in the server should check the queue and process each request from the client synchronously.服务器中的另一个服务应该检查队列并同步处理来自客户端的每个请求。

I am able to add the request in a LinkedBlocking queue.我可以在 LinkedBlocking 队列中添加请求。 How do I implement a background service or function which keeps checking the queue and executes it synchronously?如何实现后台服务或 function 不断检查队列并同步执行?

Is there a reason to put the requests in a queue?是否有理由将请求放入队列中? Did you consider using AsyncResponse to handle the requests asynchronously on the server-side?您是否考虑过使用AsyncResponse在服务器端异步处理请求?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM