修复i2内存泄漏的bug

master
liuguijing 1 year ago
parent 82f307293f
commit fc1e415fb1

@ -20,8 +20,8 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@Slf4j
@EnableConfigurationProperties
@ComponentScan(basePackages = {"com.shxy"})
@EnableCaching
@EnableAsync
//@EnableCaching
//@EnableAsync
public class I2Application {
public static void main(String[] args) {

@ -10,8 +10,6 @@ import com.shxy.i2.dao.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.cxf.endpoint.Client;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Component;
import java.math.BigInteger;
@ -21,7 +19,7 @@ import java.util.List;
@Slf4j
@Component
@EnableAsync
//@EnableAsync
public class AsyncMethod {
@Autowired
private Data_Dlq_JbfdDao data_dlq_jbfdDao;
@ -68,8 +66,11 @@ public class AsyncMethod {
@Autowired
private Upload_checkDao upload_checkDao;
@Autowired
private Client createDynamicClient;
@Async(value = "asyncServiceExecutor")
// @Async(value = "asyncServiceExecutor")
public void sendData(Client client, List<BigInteger> idlist, String xml, String type) throws Exception {
Object[] objects = client.invoke("uploadCACData", xml);
String threadId = Thread.currentThread().getName();
@ -129,7 +130,7 @@ public class AsyncMethod {
}
}
@Async(value = "asyncServiceExecutor")
// @Async(value = "asyncServiceExecutor")
public void sendJBFDData2(Client client, BigInteger maxid, ArrayList<Integer> list1, String xml, String type) throws Exception {
Object[] objects = client.invoke("uploadCACData", xml);
String threadId = Thread.currentThread().getName();
@ -166,9 +167,9 @@ public class AsyncMethod {
}
}
@Async(value = "asyncServiceExecutor")
// @Async(value = "asyncServiceExecutor")
public void sendData2(Client client, String xml) throws Exception {
Object[] objects = client.invoke("uploadCACData", xml);
Object[] objects = createDynamicClient.invoke("uploadCACData", xml);
String threadId = Thread.currentThread().getName();
log.info("线程序号: " + threadId + "当前时间:" + new Date());
if (objects != null && objects.length > 0) {
@ -193,7 +194,7 @@ public class AsyncMethod {
}
@Async(value = "asyncServiceExecutor")
// @Async(value = "asyncServiceExecutor")
public void sendYxData(Client client, BigInteger maxid, String xml) throws Exception {
// Object[] objects = client.invoke("uploadCACData", xml);
// if (objects != null && objects.length > 0) {

@ -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;
// }
//
//}

@ -5,6 +5,8 @@ public interface Webservcies {
void uploadData();
void uploadtxData();
void uploadyspData();
void uploadjfjcData();

@ -20,7 +20,7 @@ import java.util.List;
@Service
@Slf4j
@EnableAsync
//@EnableAsync
public class WebServiceImpl implements Webservcies {
@Autowired
@ -55,62 +55,52 @@ public class WebServiceImpl implements Webservcies {
public void uploadData() {
log.info("实时数据定时任务启动");
// 动态客户端
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);
log.info("开始执行定时任务-查询数据库");
HashMap<Integer, Niec_Sensors> equipMap = new HashMap();
List<Niec_Sensors> niec_sensors = niec_sensorsDao.selectAll();
for (Niec_Sensors item : niec_sensors) {
equipMap.put(item.getId(), item);
}
xydlI2Service.upload_sf6_qtyl(client, equipMap);
xydlI2Service.upload_sf6_qtyl(null, equipMap);
xydlI2Service.upload_fhdlbx(client, equipMap);
xydlI2Service.upload_fhzxq(client, equipMap);
xydlI2Service.upload_sf6_qtsf(client, equipMap);
xydlI2Service.upload_tx(client, equipMap);
xydlI2Service.upload_ws(client, equipMap);
xydlI2Service.upload_dr_jyjc(client, equipMap);
xydlI2Service.upload_fhdlbx(null, equipMap);
xydlI2Service.upload_fhzxq(null, equipMap);
xydlI2Service.upload_sf6_qtsf(null, equipMap);
xydlI2Service.upload_ws(null, equipMap);
xydlI2Service.upload_dr_jyjc(null, equipMap);
xydlI2Service.upload_microclimate(client, equipMap);
xydlI2Service.upload_cnj(client, equipMap);
xydlI2Service.upload_microclimate(null, equipMap);
xydlI2Service.upload_cnj(null, equipMap);
log.info("实时数据定时任务结束");
}
//放到配置文件
@Override
public void uploadtxData() {
log.info("实时铁芯数据定时任务启动");
// 动态客户端
log.info("开始执行定时任务-查询数据库");
HashMap<Integer, Niec_Sensors> equipMap = new HashMap();
List<Niec_Sensors> niec_sensors = niec_sensorsDao.selectAll();
for (Niec_Sensors item : niec_sensors) {
equipMap.put(item.getId(), item);
}
xydlI2Service.upload_tx(null, equipMap);
log.info("实时数据定时任务结束");
}
//放到配置文件
@Override
public void uploadyspData() {
log.info("油色谱数据定时任务启动");
// 动态客户端
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);
log.info("开始执行定时任务-查询数据库");
HashMap<Integer, Niec_Sensors> equipMap = new HashMap();
List<Niec_Sensors> niec_sensors = niec_sensorsDao.selectAll();
for (Niec_Sensors item : niec_sensors) {
equipMap.put(item.getId(), item);
}
xydlI2Service.upload_ysp(client, equipMap);
xydlI2Service.upload_ysp(null, equipMap);
log.info("油色谱数据定时任务结束");
}
@ -118,25 +108,13 @@ public class WebServiceImpl implements Webservcies {
public void uploadjfjcData() {
log.info("局放监测数据定时任务启动");
// 动态客户端
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);
HashMap<Integer, Niec_Sensors> equipMap = new HashMap();
List<Niec_Sensors> niec_sensors = niec_sensorsDao.selectAll();
for (Niec_Sensors item : niec_sensors) {
equipMap.put(item.getId(), item);
}
xydlI2Service.upload_dlq_jbfd(client, equipMap);
xydlI2Service.upload_byq_jbfd(client, equipMap);
xydlI2Service.upload_dlq_jbfd(null, equipMap);
xydlI2Service.upload_byq_jbfd(null, equipMap);
log.info("局放监测数据定时任务结束");
}
@ -144,25 +122,13 @@ public class WebServiceImpl implements Webservcies {
public void uploadyxData() {
log.info("实时数据定时任务启动");
// 动态客户端
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);
log.info("开始执行定时任务-查询数据库");
HashMap<Integer, Niec_Sensors> equipMap = new HashMap();
List<Niec_Sensors> niec_sensors = niec_sensorsDao.selectAll();
for (Niec_Sensors item : niec_sensors) {
equipMap.put(item.getId(), item);
}
xydlI2Service.upload_yx(client);
xydlI2Service.upload_yx(null);
log.info("实时数据定时任务结束");
}
@ -170,25 +136,13 @@ public class WebServiceImpl implements Webservcies {
public void uploaddcywData() {
log.info("实时数据定时任务启动");
// 动态客户端
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);
log.info("开始执行定时任务-查询数据库");
HashMap<Integer, Niec_Sensors> equipMap = new HashMap();
List<Niec_Sensors> niec_sensors = niec_sensorsDao.selectAll();
for (Niec_Sensors item : niec_sensors) {
equipMap.put(item.getId(), item);
}
xydlI2Service.upload_dcyw(client, equipMap);
xydlI2Service.upload_dcyw(null, equipMap);
log.info("实时数据定时任务结束");
}
@ -196,25 +150,13 @@ public class WebServiceImpl implements Webservcies {
public void uploadjsyhwjyjcData() {
log.info("实时数据定时任务启动");
// 动态客户端
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);
log.info("开始执行定时任务-查询数据库");
HashMap<Integer, Niec_Sensors> equipMap = new HashMap();
List<Niec_Sensors> niec_sensors = niec_sensorsDao.selectAll();
for (Niec_Sensors item : niec_sensors) {
equipMap.put(item.getId(), item);
}
xydlI2Service.upload_jsyhw_jyjc(client, equipMap);
xydlI2Service.upload_jsyhw_jyjc(null, equipMap);
log.info("实时数据定时任务结束");
}

@ -32,7 +32,7 @@ import java.util.List;
@Service
@Slf4j
@EnableAsync
//@EnableAsync
public class XydlI2ServiceImpl implements XydlI2Service {
@Autowired

@ -1,8 +1,10 @@
package com.shxy.i2.timeTask;
import com.shxy.i2.bean.AttrBean;
import com.shxy.i2.service.Webservcies;
import com.shxy.i2.service.XydlI2Service;
import lombok.extern.slf4j.Slf4j;
import org.apache.cxf.endpoint.Client;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
@ -26,14 +28,13 @@ public class ScheduledTask {
@Autowired
XydlI2Service xydlI2Service;
@Scheduled(fixedDelay = 60 * 60 * 1000)
public void cacyspupload() {
log.info("cacyspupload执行" );
webservcies.uploadyspData();
}
@Scheduled(fixedDelay = 5 * 60 * 1000)
@Scheduled(fixedDelay = 1 * 30 * 1000)
public void cacjfjcupload() {
log.info("cacjfjcupload执行" );
webservcies.uploadjfjcData();
@ -45,6 +46,12 @@ public class ScheduledTask {
webservcies.uploadData();
}
@Scheduled(fixedDelay = 1 * 30 * 1000)
public void cactxupload() {
log.info("cactxupload执行" );
webservcies.uploadtxData();
}
@Scheduled(fixedDelay = 1 * 30 * 1000)
public void cacyxupload() {
log.info("cacyxupload执行" );

Loading…
Cancel
Save