Comments (4)
记得你在QQ群里聊过这个问题,我的意思你可能还没明白,
简单描述如下:
你可以写成这样:
newRouter.rule().async(false).msgType(WxConsts.XML_MSG_EVENT).event(WxConsts.EVT_SUBSCRIBE)
.handler(this.msgHandler).end();
然后在你的msgHandler里对enventKey进行进一步判断,想用正则也是没问题的,这样的好处是可以将路由的配置和具体的实现逻辑分离,因为你的eventKey也不可能是固定写死的吧,你可以将相关的针对eventKey的判断抽出相关配置,存在数据库里,或者配置文件里,以便随时生效
from wxjava.
@binarywang 我明白你的意思了。
我会将场景值在handler 里处理。
这样写确实不太好。
另外,我还有一个问题,async 如何理解和合理使用?
查阅了 javadoc / wiki 没有详细的介绍 。
from wxjava.
async就是异步的意思,就是一个请求不会立即返回结果,一般就是单独启动进程执行,不用等待该线程执行完毕就先返回给用户一个响应。比如记录日志,或者异步发送多条消息(使用客服接口)等,都是比较常用的应用场景。你仔细阅读下源码也就能加深理解了
from wxjava.
@binarywang 好的,谢谢。
from wxjava.
Related Issues (20)
- 公众号回复文本消息换行不生效 HOT 1
- spring boot 3.0 下 jedis版本导致初始化失败 HOT 2
- 普通服务商的部分接口和平台收付通部分接口都属于服务商接口可以共用 这部分接口能不能提出来封装成公共的服务商service呢
- 【求助】序列化问题,fastjson2默认开启Gson序列化
- sendTemplateMsg 高峰期耗时很长 HOT 2
- 微信服务商支付分WxPartnerPayScoreResult确少部分字段 HOT 6
- 微信小程序增加微信物流服务退货组件相关接口 HOT 1
- 退款报错 签名错误 HOT 3
- 微信开放平台调用上传小程序代码一直提示超时,按照上面的方法修改配置还是出现此问题? HOT 3
- 创建企业群发接口WxCpMsgTemplate缺少allow_select参数 HOT 8
- 微信服务商 Native支付,v3 版本,请求 header 缺少 Authorization 参数
- commit 导致错误 2aa27cf12d4a3c7585a951e98db934b9eec9efa8 HOT 3
- 临时素材下载,无法获取到文件名 HOT 2
- 企微ticket缓存过期处理策略 HOT 1
- springboot3.0下WxMpService无法自动注入问题 HOT 4
- 微信支付配置遗漏 HOT 2
- 账单下载相关接口有误 HOT 5
- 企业微信第三方的相关回调通知的接口
- ”查询 URL Link“ 功能 HOT 1
- 微信申请退款V3接口微信时不时报异常api.mch.weixin.qq.com:443 failed to respond HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wxjava.