fix:1.优化数据同步线程池

This commit is contained in:
panbaolin 2026-05-28 18:54:57 +08:00
parent 7d2846af18
commit 87e51675a3
2 changed files with 7 additions and 10 deletions

View File

@ -12,10 +12,6 @@ import org.springframework.stereotype.Component;
@ConfigurationProperties(prefix = "data-sync")
public class DataSyncProperties {
/**
* 最小间隔分钟
*/
private Integer minMinute;
/**
* 同时最大执行数据表数量
*/

View File

@ -147,11 +147,13 @@ public class SyncDataJob implements Job {
pstmt.setString(2, syncStrategy.getTableName().toUpperCase());
pstmt.setString(3, syncStrategy.getColumnName().toUpperCase());
ResultSet rs = pstmt.executeQuery();
if (rs.next()) {
String dataType = rs.getString("data_type").toUpperCase();
return dataType.contains("DATE") || dataType.contains("TIME");
try(ResultSet rs = pstmt.executeQuery()){
if (rs.next()) {
String dataType = rs.getString("data_type").toUpperCase();
return dataType.contains("DATE") || dataType.contains("TIME");
}
}
}
return false;
}
@ -205,8 +207,7 @@ public class SyncDataJob implements Job {
int maximumPoolSize = Runtime.getRuntime().availableProcessors();
int maxExecSize = Math.min(dataSyncProperties.getMaxExecNum(), maximumPoolSize);
String threadNamePrefix = "data_sync";
int queueCapacity = maxExecSize * 2;
CustomThreadFactory threadFactory = new CustomThreadFactory(threadNamePrefix);
threadPoolExecutor = new ThreadPoolExecutor(maxExecSize,maximumPoolSize,5, TimeUnit.SECONDS,new LinkedBlockingQueue<>(queueCapacity),threadFactory);
threadPoolExecutor = new ThreadPoolExecutor(maxExecSize,(maxExecSize*2),maxExecSize, TimeUnit.SECONDS,new LinkedBlockingQueue<>(),threadFactory);
}
}