Skip to content

Commit

Permalink
🐛 #1426 修复多公众号管理的两个问题
Browse files Browse the repository at this point in the history
1、允许动态更新公众号的配置,原有逻辑:更新配置时会报“该公众号标识已存在,请更换其他标识!”;
2、多公众号的消息路由,原有逻辑问题:handler里WxMpConfigStorageHolder不能获取到appid,意味着用的wxmpservice不对,只会走默认的,已测试存在该问题
  • Loading branch information
silloy authored Mar 8, 2020
1 parent e3c6aff commit 0a99706
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,13 @@ public WxMpXmlOutMessage route(final WxMpXmlMessage wxMessage, final Map<String,
return route(wxMessage, context, null);
}

/**
* 处理不同appid微信消息
*/
public WxMpXmlOutMessage route(final String appid, final WxMpXmlMessage wxMessage, final Map<String, Object> context) {
return route(wxMessage, context, this.wxMpService.switchoverTo(appid));
}

/**
* 处理微信消息.
*/
Expand Down Expand Up @@ -228,6 +235,10 @@ public WxMpXmlOutMessage route(final WxMpXmlMessage wxMessage) {
return this.route(wxMessage, new HashMap<String, Object>(2));
}

public WxMpXmlOutMessage route(String appid, final WxMpXmlMessage wxMessage) {
return this.route(appid, wxMessage, new HashMap<String, Object>(2));
}

private boolean isMsgDuplicated(WxMpXmlMessage wxMessage) {
StringBuilder messageId = new StringBuilder();
if (wxMessage.getMsgId() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,6 @@ public void setMultiConfigStorages(Map<String, WxMpConfigStorage> configStorages
@Override
public void addConfigStorage(String mpId, WxMpConfigStorage configStorages) {
synchronized (this) {
if (this.configStorageMap.containsKey(mpId)) {
throw new RuntimeException("该公众号标识已存在,请更换其他标识!");
}
this.configStorageMap.put(mpId, configStorages);
}
}
Expand Down

0 comments on commit 0a99706

Please sign in to comment.