Giter Site home page Giter Site logo

Comments (4)

binarywang avatar binarywang commented on June 17, 2024

记得你在QQ群里聊过这个问题,我的意思你可能还没明白,
简单描述如下:
你可以写成这样:

newRouter.rule().async(false).msgType(WxConsts.XML_MSG_EVENT).event(WxConsts.EVT_SUBSCRIBE)
.handler(this.msgHandler).end();

然后在你的msgHandler里对enventKey进行进一步判断,想用正则也是没问题的,这样的好处是可以将路由的配置和具体的实现逻辑分离,因为你的eventKey也不可能是固定写死的吧,你可以将相关的针对eventKey的判断抽出相关配置,存在数据库里,或者配置文件里,以便随时生效

from wxjava.

soulmz avatar soulmz commented on June 17, 2024

@binarywang 我明白你的意思了。
我会将场景值在handler 里处理。
这样写确实不太好。
另外,我还有一个问题,async 如何理解和合理使用?
查阅了 javadoc / wiki 没有详细的介绍 。

from wxjava.

binarywang avatar binarywang commented on June 17, 2024

async就是异步的意思,就是一个请求不会立即返回结果,一般就是单独启动进程执行,不用等待该线程执行完毕就先返回给用户一个响应。比如记录日志,或者异步发送多条消息(使用客服接口)等,都是比较常用的应用场景。你仔细阅读下源码也就能加深理解了

from wxjava.

soulmz avatar soulmz commented on June 17, 2024

@binarywang 好的,谢谢。

from wxjava.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.