Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
【小程序/公众号】消息路由,使用异步消息时,向子线程传递父线程的appId的时候,兼容只有一个appId的时候,未显式设置appId的情况
  • Loading branch information
biubiubiu3971 committed Apr 29, 2023
commit 8dd138f4d91f228b6e5c94bdca94957bbd36eeb3
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,20 @@ 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()) {
//获取当前线程使用的实际appId,兼容只有一个appId,且未显式设置当前使用的appId的情况
String miniAppId = this.wxMaService.getWxMaConfig().getAppid();
futures.add(
this.executorService.submit(() -> {
//子线程中设置实际的appId
this.wxMaService.switchoverTo(miniAppId);
rule.service(wxMessage, context, WxMaMessageRouter.this.wxMaService, WxMaMessageRouter.this.sessionManager, WxMaMessageRouter.this.exceptionHandler);
WxMaConfigHolder.remove();
})
);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,16 +248,19 @@ public WxMpXmlOutMessage route(final WxMpXmlMessage wxMessage, final Map<String,

WxMpXmlOutMessage res = null;
final List<Future<?>> futures = new ArrayList<>();
String appId = WxMpConfigStorageHolder.get();

for (final WxMpMessageRouterRule rule : matchRules) {
// 返回最后一个非异步的rule的执行结果
if (rule.isAsync()) {
//获取当前线程使用的实际appId。兼容只有一个appId,且未显式设置当前使用的appId的情况
String appId = this.wxMpService.getWxMpConfigStorage().getAppId();
futures.add(
this.executorService.submit(() -> {
//传入父线程的appId
this.wxMpService.switchoverTo(appId);
rule.service(wxMessage, context, mpService, WxMpMessageRouter.this.sessionManager,
WxMpMessageRouter.this.exceptionHandler);
WxMpConfigStorageHolder.remove();
})
);
} else {
Expand Down