瀏覽代碼

Merge branch 'wyp/1125-bugFix' of Server/long-article-recommend into master

wangyunpeng 7 月之前
父節點
當前提交
6349681e81

+ 13 - 4
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/XxlJobService.java

@@ -6,7 +6,8 @@ import com.alibaba.fastjson.JSONObject;
 import com.aliyun.odps.data.Record;
 import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
 import com.google.common.collect.Lists;
-import com.tzld.longarticle.recommend.server.common.ThreadPoolFactory;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import com.tzld.longarticle.recommend.server.common.CommonThreadPoolExecutor;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.AccountBusinessTypeEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.FeishuRobotIdEnum;
 import com.tzld.longarticle.recommend.server.mapper.aigc.AigcBaseMapper;
@@ -46,7 +47,7 @@ import org.springframework.util.StringUtils;
 
 import java.time.LocalTime;
 import java.util.*;
-import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.*;
 import java.util.stream.Collectors;
 
 import static com.tzld.longarticle.recommend.server.common.constant.TimeConstant.MILLISECOND_DAY;
@@ -81,6 +82,14 @@ public class XxlJobService {
     @Autowired
     private ArticlePromotionService articlePromotionService;
 
+    ExecutorService thread = new CommonThreadPoolExecutor(
+            5,
+            5,
+            0L, TimeUnit.SECONDS,
+            new LinkedBlockingQueue<>(),
+            new ThreadFactoryBuilder().setNameFormat("XXLJOB-%d").build(),
+            new ThreadPoolExecutor.AbortPolicy());
+
     @ApolloJsonValue("${touliu.account.ghIds:[\"gh_93e00e187787\", \"gh_ac43e43b253b\", \"gh_68e7fdc09fe4\",\"gh_77f36c109fb1\", \"gh_b181786a6c8c\", \"gh_1ee2e1b39ccf\"]}")
     private List<String> touliuAccountGhIds;
 
@@ -145,7 +154,7 @@ public class XxlJobService {
             List<LongArticlesVideo> longArticlesVideoList = longArticlesVideoRepository.getByTraceIdIn(traceIds);
             CountDownLatch cdl = new CountDownLatch(longArticlesVideoList.size());
             for (LongArticlesVideo longArticlesVideo : longArticlesVideoList) {
-                ThreadPoolFactory.defaultPool().submit(() -> {
+                thread.submit(() -> {
                     try {
                         processCrawlerEachData(longArticlesVideo);
                     } finally {
@@ -238,7 +247,7 @@ public class XxlJobService {
             List<LongArticlesMatchVideo> longArticlesMatchVideoList = longArticlesMatchVideoRepository.getByTraceIdIn(traceIds);
             CountDownLatch cdl = new CountDownLatch(longArticlesMatchVideoList.size());
             for (LongArticlesMatchVideo longArticlesMatchVideo : longArticlesMatchVideoList) {
-                ThreadPoolFactory.defaultPool().submit(() -> {
+                thread.submit(() -> {
                     try {
                         processArticleEachData(longArticlesMatchVideo);
                     } finally {