修复i2内存泄漏的bug
parent
82f307293f
commit
fc1e415fb1
@ -1,35 +1,59 @@
|
|||||||
//package com.shxy.i2.configure;
|
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;
|
||||||
//
|
//
|
||||||
//import org.apache.cxf.endpoint.Client;
|
@Value("${webservice.connecttime}")
|
||||||
//import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
|
public int connecttime;
|
||||||
//import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
|
|
||||||
//import org.springframework.context.annotation.Bean;
|
@Value("${webservice.receivetime}")
|
||||||
//import org.springframework.context.annotation.Configuration;
|
public int receivetime;
|
||||||
//
|
/**
|
||||||
//@Configuration
|
* 采用代理方式
|
||||||
//public class CxfClientConfig {
|
*
|
||||||
// /**
|
* @return NBAPlayerSoap
|
||||||
// * 采用代理方式
|
*/
|
||||||
// *
|
|
||||||
// * @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"
|
|
||||||
// *
|
|
||||||
// */
|
|
||||||
// @Bean
|
// @Bean
|
||||||
// public Client createDynamicClient() {
|
// public NBAPlayerSoap createAuthorPortTypeProxy() {
|
||||||
// JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
|
// JaxWsProxyFactoryBean jaxWsProxyFactoryBean = new JaxWsProxyFactoryBean();
|
||||||
// Client client = dcf.createClient("http://www.webxml.com.cn/webservices/qqOnlineWebService.asmx?wsdl");
|
// jaxWsProxyFactoryBean.setServiceClass(NBAPlayerSoap.class);
|
||||||
// return client;
|
// 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;
|
//package com.shxy.i2.configure;
|
||||||
|
//
|
||||||
import org.springframework.context.annotation.Bean;
|
//import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
//import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.scheduling.annotation.EnableAsync;
|
//import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
//import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||||
|
//
|
||||||
import java.util.concurrent.Executor;
|
//import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
//import java.util.concurrent.ThreadPoolExecutor;
|
||||||
|
//
|
||||||
|
//
|
||||||
@Configuration
|
//@Configuration
|
||||||
@EnableAsync
|
//@EnableAsync
|
||||||
public class ThreadPoolConfig {
|
//public class ThreadPoolConfig {
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 自定义线程池配置
|
// * 自定义线程池配置
|
||||||
*
|
// *
|
||||||
* @return
|
// * @return
|
||||||
*/
|
// */
|
||||||
@Bean(name = "asyncServiceExecutor")
|
// @Bean(name = "asyncServiceExecutor")
|
||||||
public Executor asyncServiceExecutor() {
|
// public Executor asyncServiceExecutor() {
|
||||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
// ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||||
//配置核心线程数
|
// //配置核心线程数
|
||||||
executor.setCorePoolSize(50);
|
// executor.setCorePoolSize(50);
|
||||||
//配置最大线程数
|
// //配置最大线程数
|
||||||
executor.setMaxPoolSize(200);
|
// executor.setMaxPoolSize(200);
|
||||||
//配置队列大小
|
// //配置队列大小
|
||||||
executor.setQueueCapacity(1000000);
|
// executor.setQueueCapacity(1000000);
|
||||||
//配置线程池中的线程的名称前缀
|
// //配置线程池中的线程的名称前缀
|
||||||
executor.setThreadNamePrefix("async-cron-table");
|
// executor.setThreadNamePrefix("async-cron-table");
|
||||||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
// executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||||
executor.initialize();
|
// executor.initialize();
|
||||||
return executor;
|
// return executor;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
Loading…
Reference in New Issue