binarywang / weixin-java-mp-demo

基于Spring Boot 和 WxJava 实现的微信公众号Java后端Demo,支持多公众号
1.93k stars 976 forks source link

无法找到对应【default】的公众号配置信息,请核实! #150

Closed suger-pie closed 11 months ago

suger-pie commented 1 year ago

版本 4.5.0 执行完handler就会报这个错,没看懂这个 【default】到底是啥。求大佬解答

ERROR m.c.weixin.mp.api.WxMpMessageRouter - [lambda$route$1,247] -Error happened when wait task finish java.util.concurrent.ExecutionException: me.chanjar.weixin.common.error.WxRuntimeException: 无法找到对应【default】的公众号配置信息,请核实! at java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.util.concurrent.FutureTask.get(FutureTask.java:192) at me.chanjar.weixin.mp.api.WxMpMessageRouter.lambda$route$1(WxMpMessageRouter.java:239) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: me.chanjar.weixin.common.error.WxRuntimeException: 无法找到对应【default】的公众号配置信息,请核实! at me.chanjar.weixin.mp.api.impl.BaseWxMpServiceImpl.switchoverTo(BaseWxMpServiceImpl.java:529) at me.chanjar.weixin.mp.api.WxMpMessageRouter.lambda$route$0(WxMpMessageRouter.java:219) ... 5 common frames omitted

suger-pie commented 1 year ago

把异步的处理器去掉了,就不会报这个错了,看了下源码,只要处理异步任务的就会有问题:

if (matchRules.isEmpty()) { return null; } else { WxMpXmlOutMessage res = null; List<Future<?>> futures = new ArrayList(); String appId = WxMpConfigStorageHolder.get(); //这里获取的appId 为 “default” 导致下面的异步执行报错 Iterator var9 = matchRules.iterator();

            while(var9.hasNext()) {
                WxMpMessageRouterRule rule = (WxMpMessageRouterRule)var9.next();
                if (rule.isAsync()) {
                    futures.add(this.executorService.submit(() -> {
                        this.wxMpService.switchoverTo(appId);   //上面获取的appId 为 “default” 导致下面的异步执行报错
                        rule.service(wxMessage, context, mpService, this.sessionManager, this.exceptionHandler);
                    }));
                } else {
                    res = rule.service(wxMessage, context, mpService, this.sessionManager, this.exceptionHandler);
                    log.debug("End session access: async=false, sessionId={}", wxMessage.getFromUser());
                    this.sessionEndAccess(wxMessage);
                }
            }

WxMpConfigStorageHolder 这个类没有找到在哪里进行Set的

binarywang commented 11 months ago

换用最新版,V4.5.x版本