在我正在处理的一个Spring项目中,有一个用@Endpoint注释的类,并且方法用@PayloadRoot注释。在我看来,它的工作方式是同步处理请求,并且在返回对先前请求的响应之前不会处理下一个请求。
在有来自多个客户端的请求的情况下,我们如何提高性能?
谢谢, 约翰
最佳答案
每个 @Endpoint 类的作用域都是单例,可以处理来自多个客户端的请求,因此每个类都有一个线程。
查看http://docs.spring.io/spring-ws/site/reference/html/server.html中的注释:
Endpoints, like any other Spring Bean, are scoped as a singleton by default, i.e. one instance of the bean definition is created per container. Being a singleton implies that more than one thread can use it at the same time, so the endpoint has to be thread safe. If you want to use a different scope, such as prototype, refer to the Spring Reference documentation.
Note that all abstract base classes provided in Spring-WS are thread safe, unless otherwise indicated in the class-level Javadoc.
关于java - @Endpoint 注解的类处理来自多个客户端的请求,它可以是异步的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27832258/