【功能修复】Job 组件:修复多租户下,XXL-Job 无法传参的问题
parent
50e47434bb
commit
ab5c790b3d
|
@ -6,6 +6,7 @@ import cn.hutool.core.util.StrUtil;
|
|||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||
import cn.iocoder.yudao.framework.tenant.core.service.TenantFrameworkService;
|
||||
import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
|
||||
import com.xxl.job.core.context.XxlJobContext;
|
||||
import com.xxl.job.core.context.XxlJobHelper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -45,10 +46,13 @@ public class TenantJobAspect {
|
|||
// 逐个租户,执行 Job
|
||||
Map<Long, String> results = new ConcurrentHashMap<>();
|
||||
AtomicBoolean success = new AtomicBoolean(true); // 标记,是否存在失败的情况
|
||||
XxlJobContext xxlJobContext = XxlJobContext.getXxlJobContext(); // XXL-Job 上下文
|
||||
tenantIds.parallelStream().forEach(tenantId -> {
|
||||
// TODO 芋艿:先通过 parallel 实现并行;1)多个租户,是一条执行日志;2)异常的情况
|
||||
TenantUtils.execute(tenantId, () -> {
|
||||
try {
|
||||
XxlJobContext.setXxlJobContext(xxlJobContext);
|
||||
// 执行 Job
|
||||
Object result = joinPoint.proceed();
|
||||
results.put(tenantId, StrUtil.toStringOrEmpty(result));
|
||||
} catch (Throwable e) {
|
||||
|
|
Loading…
Reference in New Issue