Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot 如何在Http入站网关中同时接受固定数量的请求?_Spring Boot_Tomcat_Concurrency_Spring Integration - Fatal编程技术网

Spring boot 如何在Http入站网关中同时接受固定数量的请求?

Spring boot 如何在Http入站网关中同时接受固定数量的请求?,spring-boot,tomcat,concurrency,spring-integration,Spring Boot,Tomcat,Concurrency,Spring Integration,我正在使用Tomcat,我将http:inbound gateway作为网关,将名为request的通道配置为它的请求通道。有时我的服务上有很多请求,这会导致发生太多来自操作系统的打开文件错误。 我尝试将请求通道设置为QueChannel并为其设置容量,但它不起作用。然后,我尝试将请求通道设置为轮询消费者通道,并将具有固定延迟的轮询器设置为轮询,但它不再工作。是否有一种常规方法来限制输入请求的数量? 我如何在丢弃的请求中定制响应 <int:channel id="request">

我正在使用Tomcat,我将http:inbound gateway作为网关,将名为request的通道配置为它的请求通道。有时我的服务上有很多请求,这会导致发生太多来自操作系统的打开文件错误。 我尝试将请求通道设置为QueChannel并为其设置容量,但它不起作用。然后,我尝试将请求通道设置为轮询消费者通道,并将具有固定延迟的轮询器设置为轮询,但它不再工作。是否有一种常规方法来限制输入请求的数量? 我如何在丢弃的请求中定制响应

<int:channel id="request">
  <int:queue capacity="100"/>
</int:channel>    
...
<int-http:inbound-gateway id="RESTServiceGateway"
                        supported-methods="GET"
                        request-channel="request"
                        error-channel="errorResolver" />

<int:chain input-channel="request" output-channel="response">
<int:poller fixed-delay="1" max-messages-per-poll=""/>
...

打开的文件过多与集成流配置无关。这是关于从HTTP客户端到Tomcat的开放套接字。这个已经是并发的,可以并行处理许多请求。因此,我想说,流中的并行逻辑不会带来太多的价值,并且肯定不会影响许多打开的套接字

您可以在Tomcat中配置并发性:

另一个选项是使用ulimit工具增加Linux上打开文件的数量:

<task:executor id="requestExecutor" pool-size="1-10" queue-capacity="10"/>
<int:channel id="request">
    <int:dispatcher task-executor="requestExecutor"/>
</int:channel>
<int-http:inbound-gateway id="RESTServiceGateway"
                        supported-methods="GET"
                        request-channel="request"
                        error-channel="errorResolver" />

<int:chain input-channel="request" output-channel="response">
...