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)
- com.thoughtworks.xstream.security.ForbiddenClassException HOT 4
- 视频号订单缺失属性AddressInfo.hash_code HOT 1
- 【feature】获取汇报记录详情
- 微信支付多商户号问题
- WxChannel 视频号板块 没有分享员绑定接口通知 HOT 1
- markdown HOT 1
- MP_微信消息路由器,异步出路,收不到回复的消息 HOT 5
- 使用 MybatisPlus 多租户插件疑问 HOT 5
- 微信小程序用户信息解密方法不返回openid吗 HOT 6
- 是否可以加入企业微信文档相关接口 HOT 1
- 支持java21的版本有嘛?
- 企微第三方加好友回调,创建时间一样被判定为重复消息 HOT 2
- 该公众号提供服务出现故障,请稍后重试 HOT 5
- HttpResponseProxy#extractFileNameFromContentString 正则匹配失败
- WxMpHostConfig地址需要支持配置化 HOT 1
- 支付私钥字符串BUG
- TransferCreateResult 商家转账到零钱,新增 batch_status 返回值,版本4.6.0 HOT 1
- https://developer.work.weixin.qq.com/document/path/97126 HOT 1
- weixin-java-cp-solon-plugin redisson配置失败 HOT 3
- 可否增加小程序 生物认证秘钥签名验证 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.