简体   繁体   English

具有内部线程机制的Java REST Web服务

[英]Java REST Web Service with internal threading mechanism

I have a data-push web service implemented in REST which pushes the data in database. 我有一个在REST中实现的数据推送Web服务,该服务将数据推送到数据库中。

Now I want to create one more web service which will take input from a data-push web service and perform some business logic for any alerts. 现在,我想再创建一个Web服务,该服务将接收来自数据推送Web服务的输入,并对任何警报执行一些业务逻辑。 If any alert is present then it will call an alert service. 如果存在任何警报,则它将调用警报服务。 In this case data-push web service should detach as soon as it posts the required data. 在这种情况下,数据推送Web服务在发布所需数据后应立即分离。

My doubt is if there are too many request on data-push web service - lets say for every second - then how will it handle threading mechanism and post on new web service? 我的疑问是,如果对数据推送Web服务的请求过多-每秒说一次-那么它将如何处理线程机制并发布在新Web服务上?

If you are worried about the throughput of the service pushing data, you can queue the data push requests up and have a pool of worker threads process them as time and system resources permit. 如果您担心服务推送数据的吞吐量,可以将数据推送请求排入队列,并在时间和系统资源允许的情况下让工作线程池处理这些请求。

The queuing mechanism could be any number of solutions depending on your scalability and throughput requirements: 排队机制可以是多种解决方案,具体取决于您的可伸缩性和吞吐量要求:

  1. In-Memory 在记忆中
  2. JMS Messaging Middleware JMS消息传递中间件
  3. Relational Database 关系型数据库
  4. Distributed Cache 分布式缓存

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

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