Commit 9ef04287 by 周立明

refactor(goods-listing): 异步处理商品上架逻辑并增加异常捕获

将原同步的商品上架处理改为异步执行,同时添加全局异常捕获避免事务同步回调出错影响主流程
1 parent b17ec07d
...@@ -407,6 +407,8 @@ public class GoodsListingApprovalService { ...@@ -407,6 +407,8 @@ public class GoodsListingApprovalService {
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() { TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override @Override
public void afterCommit() { public void afterCommit() {
try {
taskExecutor.execute(() -> {
if(CollectionUtils.isNotEmpty(context.details)){ if(CollectionUtils.isNotEmpty(context.details)){
context.details.forEach(item ->{ context.details.forEach(item ->{
MerchantGoodsInfoDTO merchantGoodsInfo = MerchantGoodsInfoDTO.builder() MerchantGoodsInfoDTO merchantGoodsInfo = MerchantGoodsInfoDTO.builder()
...@@ -417,6 +419,10 @@ public class GoodsListingApprovalService { ...@@ -417,6 +419,10 @@ public class GoodsListingApprovalService {
log.info("上架ID:{}处理完成,处理结果:{}",item.getMerchantGoodsCode(),res); log.info("上架ID:{}处理完成,处理结果:{}",item.getMerchantGoodsCode(),res);
}); });
} }
});
}catch(Exception e) {
log.error(e.getMessage(),e);
}
} }
}); });
} catch (RpcServiceException e) { } catch (RpcServiceException e) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!