Parcourir la source

待发布文章提前拉取 线程数配置

wangyunpeng il y a 1 mois
Parent
commit
2a54f6ad0f

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

@@ -60,6 +60,7 @@ import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.utils.URIBuilder;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.dao.DuplicateKeyException;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
@@ -146,6 +147,9 @@ public class XxlJobService {
             "\"20241030070010871546586\"]}")
     private static List<String> producePlanIds;
 
+    @Value("${sync.publish.content.thread.pool.size:5}")
+    private static Integer syncPublishContentThreadPoolSize;
+
     @XxlJob("checkPublishPlan")
     public ReturnT<String> checkPublishPlan(String param) {
         Long todayStart = DateUtils.getTodayStart();
@@ -984,6 +988,12 @@ public class XxlJobService {
         List<PublishPlanAccountDTO> accountList = publishContentMapper.getPublishPlanAccounts(planIds);
         Collections.shuffle(accountList);
         CountDownLatch cdl = new CountDownLatch(accountList.size());
+
+        ExecutorService thread = new CommonThreadPoolExecutor(
+                syncPublishContentThreadPoolSize, syncPublishContentThreadPoolSize, 0L, TimeUnit.SECONDS,
+                new LinkedBlockingQueue<>(),
+                new ThreadFactoryBuilder().setNameFormat("syncGzhWaitingPublishContent-%d").build(),
+                new ThreadPoolExecutor.AbortPolicy());
         for (PublishPlanAccountDTO account : accountList) {
             thread.submit(() -> {
                 try {