Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【小程序】路由规则使用异步时,当前的appId没有传入到子线程,导致wxMaService在子线程中无法取到父线程的appId。 #2961

Merged
merged 1 commit into from
Mar 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaMessage;
import cn.binarywang.wx.miniapp.util.WxMaConfigHolder;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import lombok.Data;
import me.chanjar.weixin.common.api.WxErrorExceptionHandler;
Expand Down Expand Up @@ -127,14 +128,15 @@ public WxMaXmlOutMessage route(final WxMaMessage wxMessage, final Map<String, Ob
if (matchRules.size() == 0) {
return null;
}

String miniAppId = WxMaConfigHolder.get();
final List<Future<?>> futures = new ArrayList<>();
WxMaXmlOutMessage result = null;
for (final WxMaMessageRouterRule rule : matchRules) {
// 返回最后一个非异步的rule的执行结果
if (rule.isAsync()) {
futures.add(
this.executorService.submit(() -> {
this.wxMaService.switchoverTo(miniAppId);
rule.service(wxMessage, context, WxMaMessageRouter.this.wxMaService, WxMaMessageRouter.this.sessionManager, WxMaMessageRouter.this.exceptionHandler);
})
);
Expand Down