Commit 9ef04287 by 周立明

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

将原同步的商品上架处理改为异步执行,同时添加全局异常捕获避免事务同步回调出错影响主流程
1 parent b17ec07d
...@@ -407,16 +407,22 @@ public class GoodsListingApprovalService { ...@@ -407,16 +407,22 @@ public class GoodsListingApprovalService {
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() { TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
@Override @Override
public void afterCommit() { public void afterCommit() {
if(CollectionUtils.isNotEmpty(context.details)){ try {
context.details.forEach(item ->{ taskExecutor.execute(() -> {
MerchantGoodsInfoDTO merchantGoodsInfo = MerchantGoodsInfoDTO.builder() if(CollectionUtils.isNotEmpty(context.details)){
.updatedBy(updatedBy) context.details.forEach(item ->{
.merchantGoodsCodeList(Arrays.asList(item.getMerchantGoodsCode())) MerchantGoodsInfoDTO merchantGoodsInfo = MerchantGoodsInfoDTO.builder()
.build(); .updatedBy(updatedBy)
RpcResponse<Boolean> res = merchantGoodsInfoRemote.onShelfHandler(merchantGoodsInfo); .merchantGoodsCodeList(Arrays.asList(item.getMerchantGoodsCode()))
log.info("上架ID:{}处理完成,处理结果:{}",item.getMerchantGoodsCode(),res); .build();
}); RpcResponse<Boolean> res = merchantGoodsInfoRemote.onShelfHandler(merchantGoodsInfo);
} 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!