ES异步同步数据
This commit is contained in:
+5
-10
@@ -178,16 +178,11 @@ public class HomeSearchCheckEsPlanJob implements Job {
|
|||||||
endIndex = startIndex + batchCount;
|
endIndex = startIndex + batchCount;
|
||||||
}
|
}
|
||||||
List<String> ids = listIds.subList(startIndex, endIndex);
|
List<String> ids = listIds.subList(startIndex, endIndex);
|
||||||
// 异步生成记录
|
try {
|
||||||
ForkJoinPool pool = new ForkJoinPool();
|
lawsHomeSearchService.updateEsData(lawsNewsFeed, String.join(",", ids), LawsHomeSearchCommon.LAWS_ES_ADD);
|
||||||
// 异步调用
|
} catch (Exception e) {
|
||||||
CompletableFuture.runAsync(() -> {
|
log.error("ES同步异常:", e.getMessage());
|
||||||
try {
|
}
|
||||||
lawsHomeSearchService.updateEsData(lawsNewsFeed, String.join(",", ids), LawsHomeSearchCommon.LAWS_ES_ADD);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("ES同步异常:", e.getMessage());
|
|
||||||
}
|
|
||||||
}, pool);
|
|
||||||
startIndex = startIndex + batchCount; // 下一批
|
startIndex = startIndex + batchCount; // 下一批
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+27
-24
@@ -842,31 +842,34 @@ public class LawsHomeSearchServiceImpl implements ILawsHomeSearchService {
|
|||||||
throw new JeroBootException(ResultCommon.PARAMETER_NOT_RECOGNIZED);
|
throw new JeroBootException(ResultCommon.PARAMETER_NOT_RECOGNIZED);
|
||||||
}
|
}
|
||||||
log.info("================ES更新数据开始=================");
|
log.info("================ES更新数据开始=================");
|
||||||
try{
|
ForkJoinPool pool = new ForkJoinPool();
|
||||||
//判断索引是否存在
|
CompletableFuture.runAsync(()->{
|
||||||
boolean flagTemp;
|
try{
|
||||||
flagTemp = jeroElasticsearchTemplate.indexExists(HomeSearchEnum.INDEX_NAME_DOCUMENT_ZQ.getValue());
|
//判断索引是否存在
|
||||||
if (!flagTemp) {
|
boolean flagTemp;
|
||||||
jeroElasticsearchTemplate.createIndex(HomeSearchEnum.INDEX_NAME_DOCUMENT_ZQ.getValue());
|
flagTemp = jeroElasticsearchTemplate.indexExists(HomeSearchEnum.INDEX_NAME_DOCUMENT_ZQ.getValue());
|
||||||
|
if (!flagTemp) {
|
||||||
|
jeroElasticsearchTemplate.createIndex(HomeSearchEnum.INDEX_NAME_DOCUMENT_ZQ.getValue());
|
||||||
|
}
|
||||||
|
switch (resourceType){
|
||||||
|
case LawsHomeSearchCommon.LAWS_DOMESTIC_STANDARD:
|
||||||
|
updateLawsDomesticStandardToEs(resourceType,ids,opType);
|
||||||
|
break;
|
||||||
|
case LawsHomeSearchCommon.LAWS_OVERSEAS_STANDARD:
|
||||||
|
updateLawsOverseasStandardToEs(resourceType,ids,opType);
|
||||||
|
break;
|
||||||
|
case LawsHomeSearchCommon.LAWS_ENTERPRISE_STANDARD:
|
||||||
|
updateLawsEnterpriseStandardToEs(resourceType,ids,opType);
|
||||||
|
break;
|
||||||
|
case LawsHomeSearchCommon.LAWS_NEWS_FEED:
|
||||||
|
updateLawsNewsFeedToEs(resourceType,ids,opType);
|
||||||
|
break;
|
||||||
|
default:break;
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("ES同步异常",e.getMessage());
|
||||||
}
|
}
|
||||||
switch (resourceType){
|
},pool);
|
||||||
case LawsHomeSearchCommon.LAWS_DOMESTIC_STANDARD:
|
|
||||||
updateLawsDomesticStandardToEs(resourceType,ids,opType);
|
|
||||||
break;
|
|
||||||
case LawsHomeSearchCommon.LAWS_OVERSEAS_STANDARD:
|
|
||||||
updateLawsOverseasStandardToEs(resourceType,ids,opType);
|
|
||||||
break;
|
|
||||||
case LawsHomeSearchCommon.LAWS_ENTERPRISE_STANDARD:
|
|
||||||
updateLawsEnterpriseStandardToEs(resourceType,ids,opType);
|
|
||||||
break;
|
|
||||||
case LawsHomeSearchCommon.LAWS_NEWS_FEED:
|
|
||||||
updateLawsNewsFeedToEs(resourceType,ids,opType);
|
|
||||||
break;
|
|
||||||
default:break;
|
|
||||||
}
|
|
||||||
}catch (Exception e){
|
|
||||||
log.error("ES同步异常",e.getMessage());
|
|
||||||
}
|
|
||||||
log.info("================ES更新数据结束=================");
|
log.info("================ES更新数据结束=================");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user