GithubHelp home page GithubHelp logo

Comments (10)

binarywang avatar binarywang commented on May 20, 2024

@wesleywu
建议收看下这篇博文,希望对你有帮助

from wxjava.

wesleywu avatar wesleywu commented on May 20, 2024

谢谢,看了这篇博文。对我们目前的帮助似乎不是特别大,思路有借鉴,关键是要降低同步块的执行时间。目前这个方法的同步关键词似乎是为了解决token过期以后的重取
token问题,那只需要在刷新token的地方加同步即可,而没必要在这个方法上加,不知我的理解是否对。

另外,我建议把底层的http库换成okhttp,并且需要加入一些并发压力测试的用例。

这些工作我可以帮忙做。

from wxjava.

binarywang avatar binarywang commented on May 20, 2024

没问题,你可以做相关调整直接提交代码并做好测试,感谢帮忙共同维护好这个SDK

from wxjava.

chanjarster avatar chanjarster commented on May 20, 2024

时间比较久远已经忘记了,不过似乎和刷新access token有关。

如果在access token失效的时候有大量请求发出,那么就会造成并发刷新access token,导致access token的单日刷新次数用尽,以及程序不断得刷新access token。

https://github.com/chanjarster/weixin-java-tools/issues/323#issuecomment-240055919@zxkane 说的思路不错,应该采用异步的方式,使用队列比较好,比如弄个100个队列,取模让队列处理。

不过还是要考虑如何避免并发刷新access token的问题,而且这个问题也同时存在于集群环境。没想过怎么搞。

from wxjava.

bysunexus avatar bysunexus commented on May 20, 2024

http://mp.weixin.qq.com/wiki/11/0e4b294685f817b95cbed85ba5e82b8f.html

2、目前access_token的有效期通过返回的expire_in来传达,目前是7200秒之内的值。中控服务器需要根据这个有效时间提前去刷新新access_token。在刷新过程中,中控服务器对外输出的依然是老access_token,此时公众平台后台会保证在刷新短时间内,新老access_token都可用,这保证了第三方业务的平滑过渡;

刷新时可以短期保证新老token均有效

中秋期间有时间提交一个pr修改一下这里的实现

from wxjava.

binarywang avatar binarywang commented on May 20, 2024

@kakotor 期待你的新代码

from wxjava.

yigubigu avatar yigubigu commented on May 20, 2024

#1 使用redis,把access_token
#2 中控服务器定期刷新,拿到后立即更新
#3保 证刷新的线程是高优先级,能够始终执行

from wxjava.

biageng888 avatar biageng888 commented on May 20, 2024

中控access_token还是缓存中处理好些,请求大时,线程控制是个问题,不知有无更好解决方案。

from wxjava.

anjia0532 avatar anjia0532 commented on May 20, 2024

可以考虑增加分布式缓存 Hazelcast 比 redis 轻量

from wxjava.

binarywang avatar binarywang commented on May 20, 2024

时间太长,暂时关闭此issue,如果使用新版本发现有此问题,请开启新issue单独讨论。

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.