简体   繁体   English

春天。 Spring 如何管理控制器

[英]Spring. How does Spring manage Controllers

I am developing an API using spring and I have some doubts.我正在使用 spring 开发 API,我有一些疑问。 Imagine I have a @Controller which one of it's endpoints takes 2 minutes to process a response.想象一下,我有一个@Controller ,它的一个端点需要 2 分钟来处理响应。 If I do multiple petitions with different users at the same time to that specific endpoint.如果我同时向该特定端点向不同用户发出多个请求。

How does Spring manage it? Spring 是如何管理它的? Is it concurrent?是并发的吗?

In theory the controllers are Singleton, therefore the controller wouldn't be able to answer the next petition before he ends the last one.理论上控制器是单身人士,因此控制器在他结束最后一个请求之前将无法回答下一个请求。

Thanks谢谢

The controllers are Singleton for sure, but they can be accessed concurrently.控制器肯定是单例的,但它们可以同时访问。 So many user requests can be handled in parallel by the same controller.如此多的用户请求可以由同一个控制器并行处理。 That is why your controller should be stateless, that is, you should not store user data in the controller attributes.这就是为什么你的控制器应该是无状态的,也就是说,你不应该在控制器属性中存储用户数据。

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

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