Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 9k
Closed
Labels
Description
简要描述
在 CP_如何支持多个企业号的wiki中CP的基本配置信息(secret,token,aesKey)都是配置在配置文件中的,然后启动服务的时候直接生成了多个WxCpService然后存储在map中
@PostConstructpublicvoidinitServices(){cpServices = this.properties.getAppConfigs().stream().map(a ->{valconfigStorage = newWxCpDefaultConfigImpl(); configStorage.setCorpId(this.properties.getCorpId()); configStorage.setAgentId(a.getAgentId()); configStorage.setCorpSecret(a.getSecret()); configStorage.setToken(a.getToken()); configStorage.setAesKey(a.getAesKey()); valservice = newWxCpServiceImpl(); service.setWxCpConfigStorage(configStorage); routers.put(a.getAgentId(), this.newRouter(service)); returnservice}).collect(Collectors.toMap(service -> service.getWxCpConfigStorage().getAgentId(), a -> a))}问题
我的服务中有很多个CP的配置信息(100个)并且都存在数据库中,我感觉在项目启动的时候生成100个WxCpService非常不妥,并且这个配置信息还会动态递增(每接入一个CP用户,我就要在数据库中新增一条配置信息),请问有较好的方式解决这个问题吗。
就比如说我需要调用某个CP用户的接口,就根据数据库里面的配置信息为它生成一个WxCpService,主要的步骤就是每次都需要调用setWxCpConfigStorage把数据库存储的配置注入进去,但是setWxCpConfigStorage方法中有一个initHttp(),频繁的调用initHttp()会有性能影响吗