我正在使用WebServiceTemplate使用soap服务,它在spring3+中运行良好,性能良好。
spring :- 3.2.4.RELEASE
spring-ws-core :- 2.1.4.RELEASE
spring-ws-support :- 2.1.4.RELEASE
spring-ws-security :-2.1.4.RELEASE类,用于调用soap服务
SaajSoapMessageFactory messageFactory = new SaajSoapMessageFactory(MessageFactory.newInstance());
messageFactory.afterPropertiesSet();
WebServiceTemplate webServiceTemplate = new WebServiceTemplate(messageFactory);
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setContextPath("some package");
marshaller.afterPropertiesSet();
webServiceTemplate.setMarshaller(marshaller);
webServiceTemplate.setUnmarshaller(marshaller);
webServiceTemplate.afterPropertiesSet();
webServiceTemplate.setInterceptors(clientInterceptors);
webServiceTemplate.setMessageSender(webServiceMessageSenderWithAuth);
webServiceTemplate.setDefaultUri(url);
Output result= ((JAXBElement<Output >) webServiceTemplate.marshalSendAndReceive(jaxbRequest)).getValue();配置文件
@Configuration
public class WebServiceConfiguration {
@Autowired
private SaajSoapMessageFactory messageFactory;
@Autowired
private WebServiceMessageSenderWithAuth webServiceMessageSenderWithAuth;
@Bean
public Wss4jSecurityInterceptor getWss4jSecurityInterceptor(@Value("${WSDL.UserName}") String userName,
@Value("${WSDL.Password}") String password) {
Wss4jSecurityInterceptor wss4jSecurityInterceptor = new Wss4jSecurityInterceptor();
wss4jSecurityInterceptor.setSecurementActions("UsernameToken");
wss4jSecurityInterceptor.setSecurementPasswordType("PasswordText");
wss4jSecurityInterceptor.setSecurementUsername(userName);
wss4jSecurityInterceptor.setSecurementPassword(password);
return wss4jSecurityInterceptor;
}
@Bean
public SaajSoapMessageFactory getSaajSoapMessageFactory() {
return new SaajSoapMessageFactory();
}
@Bean
public ClientInterceptor[] clientInterceptors(Wss4jSecurityInterceptor wsSecurityInterceptor) {
return new ClientInterceptor[] { wsSecurityInterceptor };
}
}性能结果时间--大约500 max 平均时间,最大时间:- 1秒
弹簧启动1.5.20和2.2.2
使用spring引导相同的代码,没有任何改变,第一次调用大约需要4秒,如果继续命中相同的代码,则大约需要2秒。
弹簧引导的性能结果
第一个呼叫:- 4秒
后续调用没有间隔(1-10秒间隔) :- 2秒到800 ms
它在不断减少的同时,用较少的间隔一次又一次地进行相同的呼叫,并下降到spring 3的类似结果,但如果经过5分钟这样的时间间隔后再尝试,则在5分钟后再次尝试相同的模式,5分钟后再尝试,则第一次和以后的调用结果相同。
注意:AxiomSoapMessageFactory -使用弹簧引导,我也尝试了wss4j,而不是wss4j2,也尝试了,但是没有运气。
发布于 2019-12-26 12:49:04
所以问题不在于代码。我终于把它部署到上了.它只是在没有任何一行更改的情况下就开始执行得很好了。
现在300 its 到500 its。因此,问题在于嵌入式tomcat和嵌入式码头不好。
发布于 2019-12-26 02:17:52
缓存可能是导致上述结果的因素之一。
缓存是提高系统性能的一种机制。它是介于应用程序和持久数据库之间的临时内存。高速缓存存储器存储最近使用的数据项,以尽可能减少数据库命中次数。
JVM热身效应
当基于JVM的应用程序启动时,它收到的第一个请求通常比平均响应时间慢得多。这个热身效应通常是由于启动时的类加载和字节码解释造成的。
为了进一步优化应用程序,请使用超持久性优化器,它允许您通过扫描应用程序配置和映射来充分利用JPA和Spring。
运行超级优化器非常容易,因为您只需将EntityManagerFactory实例传递给HypersistenceOptimizer对象构造函数,并调用init方法即可。
我想您已经这样做了,但是如果没有,请看一下更快的StartUp,并在那里实现建议的修复。
对于使用嵌入式tomcat禁用扫描,在这里的注释中有一个建议-- Tomcat JarScanning
在SpringBootApplication中启用异步调用
@EnableSync
@SpringBootApplication
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}https://stackoverflow.com/questions/59455169
复制相似问题