修复i2内存泄漏的bug
parent
82f307293f
commit
fc1e415fb1
@ -1,35 +1,59 @@
|
||||
//package com.shxy.i2.configure;
|
||||
//
|
||||
//import org.apache.cxf.endpoint.Client;
|
||||
//import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
|
||||
//import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
|
||||
//import org.springframework.context.annotation.Bean;
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//
|
||||
//@Configuration
|
||||
//public class CxfClientConfig {
|
||||
// /**
|
||||
// * 采用代理方式
|
||||
// *
|
||||
// * @return NBAPlayerSoap
|
||||
// */
|
||||
//// @Bean
|
||||
//// public NBAPlayerSoap createAuthorPortTypeProxy() {
|
||||
//// JaxWsProxyFactoryBean jaxWsProxyFactoryBean = new JaxWsProxyFactoryBean();
|
||||
//// jaxWsProxyFactoryBean.setServiceClass(NBAPlayerSoap.class);
|
||||
//// jaxWsProxyFactoryBean.setAddress(WsConst.SERVICE_ADDRESS);
|
||||
//// return (NBAPlayerSoap) jaxWsProxyFactoryBean.create();
|
||||
//// }
|
||||
//
|
||||
// /**
|
||||
// * 采用动态工厂方式 不需要指定服务接口
|
||||
// * "http://www.webxml.com.cn/webservices/qqOnlineWebService.asmx?wsdl"
|
||||
// *
|
||||
// */
|
||||
package com.shxy.i2.configure;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.cxf.endpoint.Client;
|
||||
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
|
||||
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
|
||||
import org.apache.cxf.transport.http.HTTPConduit;
|
||||
import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class CxfClientConfig {
|
||||
@Value("${webservice.address}")
|
||||
public String address;
|
||||
//
|
||||
@Value("${webservice.connecttime}")
|
||||
public int connecttime;
|
||||
|
||||
@Value("${webservice.receivetime}")
|
||||
public int receivetime;
|
||||
/**
|
||||
* 采用代理方式
|
||||
*
|
||||
* @return NBAPlayerSoap
|
||||
*/
|
||||
// @Bean
|
||||
// public Client createDynamicClient() {
|
||||
// JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
|
||||
// Client client = dcf.createClient("http://www.webxml.com.cn/webservices/qqOnlineWebService.asmx?wsdl");
|
||||
// return client;
|
||||
// public NBAPlayerSoap createAuthorPortTypeProxy() {
|
||||
// JaxWsProxyFactoryBean jaxWsProxyFactoryBean = new JaxWsProxyFactoryBean();
|
||||
// jaxWsProxyFactoryBean.setServiceClass(NBAPlayerSoap.class);
|
||||
// jaxWsProxyFactoryBean.setAddress(WsConst.SERVICE_ADDRESS);
|
||||
// return (NBAPlayerSoap) jaxWsProxyFactoryBean.create();
|
||||
// }
|
||||
//}
|
||||
|
||||
/**
|
||||
* 采用动态工厂方式 不需要指定服务接口
|
||||
* "http://www.webxml.com.cn/webservices/qqOnlineWebService.asmx?wsdl"
|
||||
*
|
||||
*/
|
||||
@Bean
|
||||
public Client createDynamicClient() {
|
||||
// 动态客户端
|
||||
JaxWsDynamicClientFactory clientFactory = JaxWsDynamicClientFactory.newInstance();
|
||||
log.info("实时数据 publicsecurity webService url : {}", address);
|
||||
//根据WebServices接口地址创建client
|
||||
Client client = clientFactory.createClient(address);
|
||||
HTTPConduit conduit = (HTTPConduit) client.getConduit();
|
||||
HTTPClientPolicy policy = new HTTPClientPolicy();
|
||||
policy.setAllowChunking(false);
|
||||
// 连接服务器超时时间 60秒
|
||||
policy.setConnectionTimeout(connecttime);
|
||||
// 等待服务器响应超时时间 60秒
|
||||
policy.setReceiveTimeout(receivetime);
|
||||
conduit.setClient(policy);
|
||||
return client;
|
||||
}
|
||||
}
|
||||
|
@ -1,37 +1,37 @@
|
||||
package com.shxy.i2.configure;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
|
||||
@Configuration
|
||||
@EnableAsync
|
||||
public class ThreadPoolConfig {
|
||||
|
||||
/**
|
||||
* 自定义线程池配置
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Bean(name = "asyncServiceExecutor")
|
||||
public Executor asyncServiceExecutor() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
//配置核心线程数
|
||||
executor.setCorePoolSize(50);
|
||||
//配置最大线程数
|
||||
executor.setMaxPoolSize(200);
|
||||
//配置队列大小
|
||||
executor.setQueueCapacity(1000000);
|
||||
//配置线程池中的线程的名称前缀
|
||||
executor.setThreadNamePrefix("async-cron-table");
|
||||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
executor.initialize();
|
||||
return executor;
|
||||
}
|
||||
|
||||
}
|
||||
//package com.shxy.i2.configure;
|
||||
//
|
||||
//import org.springframework.context.annotation.Bean;
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//import org.springframework.scheduling.annotation.EnableAsync;
|
||||
//import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
//
|
||||
//import java.util.concurrent.Executor;
|
||||
//import java.util.concurrent.ThreadPoolExecutor;
|
||||
//
|
||||
//
|
||||
//@Configuration
|
||||
//@EnableAsync
|
||||
//public class ThreadPoolConfig {
|
||||
//
|
||||
// /**
|
||||
// * 自定义线程池配置
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// @Bean(name = "asyncServiceExecutor")
|
||||
// public Executor asyncServiceExecutor() {
|
||||
// ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
// //配置核心线程数
|
||||
// executor.setCorePoolSize(50);
|
||||
// //配置最大线程数
|
||||
// executor.setMaxPoolSize(200);
|
||||
// //配置队列大小
|
||||
// executor.setQueueCapacity(1000000);
|
||||
// //配置线程池中的线程的名称前缀
|
||||
// executor.setThreadNamePrefix("async-cron-table");
|
||||
// executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
// executor.initialize();
|
||||
// return executor;
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
Loading…
Reference in New Issue