响应式编程查询记录
概念听了很久,文章也浏览了不少,看起来就是异步编程,我更关注怎么应用到当前的一下项目设计中;
下面就试一试,测试项目地址:
https://github.com/eugenp/tutorials/tree/master/spring-5-webflux;
关于Flux和Mono的区别和API我感觉下面的这几个链接说的比较清楚:
https://blog.csdn.net/lmq2582609/article/details/91987792
https://blog.csdn.net/get_set/article/details/79480172
https://www.xttblog.com/%3Fp%3D3885
https://blog.csdn.net/get_set/article/details/79492439
看到一个评论:
https://medium.com/faun/reactive-programming-using-spring-webflux-ad3cfc6f0471
https://howtodoinjava.com/spring-webflux/spring-webflux-tutorial/
https://dzone.com/articles/reactor-core-tutorial
https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html
https://stackoverflow.com/questions/51160076/spring-5-webflux-mono-and-flux
https://www.baeldung.com/spring-debugging-reactive-streams
https://auth0.com/blog/introduction-getting-started-with-spring-webflux-api/
总结除了记几点:
Flux至多N个(0...N),Mono至多1个(0...1),达到数目或者出错都会结束;(感觉措辞还要修改)
...
spring webflux是在5中才比较完善的jdk8+,当jdk8-时可以考虑rxjava,rxjava2和reactor webflux是对统一标准的不同实现;
关于注解的对比:
前面的项目主要还是在spring mvc4.x环境下, 所以看到5中的控制器流行写法感觉不太适应,所以对比一下:
@Controller @RequestMapping("/example/") public class ExampleController { @RequestMapping(value="api/aaa.json" , method=RequestMethod.POST, name="aaa",produces = "application/json;charset=utf-8",consumes = MediaType.APPLICATION_JSON_VALUE ) @ResponseBody public Map<String,Object> aaaa(@RequestBody Map<String, Object> paramMap,HttpServletRequest request) throws Exception { } @RequestMapping(value="api/bbb.json" , method=RequestMethod.POST, name="bbb",produces = "application/json;charset=utf-8") @ResponseBody public Map<String,Object> bbb(@RequestParam("xxx") int xxx,Principal principal, HttpServletRequest request) throws Exception{ List<GrantedAuthority> ifo = new ArrayList<GrantedAuthority>(((AAA)principal).getAuthorities()); } @RequestMapping(value="upload/ccc.json", method=RequestMethod.POST, name="ccc",consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = "text/html;charset=UTF-8") @ResponseBody public String ccc(@RequestParam("Filedata") MultipartFile multipart, HttpServletRequest request,HttpServletResponse response) throws Exception { } @RequestMapping(value="api/ddd.json", method=RequestMethod.POST, name="ddd",consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) @ResponseBody public Map<String,Object> ddd(@RequestParam HashMap<String, Object> formData,Principal principal, HttpServletRequest request) throws Exception { } }
对比于
@RequestMapping("/example") @RestController public class ExampleController { @GetMapping(value = "/no-content", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @ResponseStatus(HttpStatus.NO_CONTENT) public Flux<String> noContent() { return Flux.empty(); } }
差别没多大,只不过一种写法看习惯后,突然看另一种写法会比较不适应而已;
参考:
http://www.appsdeveloperblog.com/spring-mvc-postmapping-getmapping-putmapping-deletemapping/
/*-----------------------------------------------分割线------------------------------------------------------------------*/
参考:
https://halfrost.com/functional_reactive_programming_concept/
https://yq.aliyun.com/articles/639744
https://stackoverflow.com/questions/56461260/java-spring-webflux-vs-rxjava
https://medium.com/mindorks/rxjava-operator-map-vs-flatmap-427c09678784
https://www.nurkiewicz.com/2019/02/rxjava-vs-reactor.html
https://blog.danlew.net/2016/01/25/rxjavas-repeatwhen-and-retrywhen-explained/
https://www.baeldung.com/spring-5-reactive-websockets
https://mlog.club/article/16255
https://www.jianshu.com/p/035db36c5918
https://www.academind.com/learn/javascript/callbacks-vs-promises-vs-rxjs-vs-async-awaits/
https://medium.com/javascript-in-plain-english/promise-vs-observable-vs-stream-165a310e886f
https://medium.com/yammer-engineering/converting-callback-async-calls-to-rxjava-ebc68bde5831
https://www.baeldung.com/spring-boot-reactor-netty
https://stackify.com/reactive-spring-5/
https://www.slideshare.net/Pivotal/reactive-web-101-webflux-webclient-and-reactor-netty
:https://www.oreilly.com/radar/reactive-programming-vs-reactive-systems/
https://www.baeldung.com/spring-webflux
/*----------------------------分割线-------------------------------------*/
https://blog.csdn.net/eric520zenobia/article/details/53766571
https://github.com/protostuff/protostuff
http://hengyunabc.github.io/thinking-about-grpc-protobuf/
https://blog.csdn.net/zhglance/article/details/56017926
https://colobu.com/2019/10/03/protobuf-ultimate-tutorial-in-go/
https://github.com/grpc/grpc/blob/master/CONTRIBUTING.md
/*-------------------------------分割线------------------------------------------*/
java异步爬虫
参考:
https://github.com/wuxudong/rxcrawler
https://github.com/hjander/rxjava-crawler
https://stackoverflow.com/questions/56461260/java-spring-webflux-vs-rxjava
https://www.slideshare.net/Pivotal/reactive-web-101-webflux-webclient-and-reactor-netty
https://github.com/reactor/reactor-netty
https://www.baeldung.com/spring-boot-reactor-netty
https://github.com/eugenp/tutorials/tree/master/spring-5-webflux
https://blog.csdn.net/hety119/article/details/84880559
https://pmd.github.io/latest/pmd_userdocs_tools_maven.html
https://stackoverflow.com/questions/42444457/lombok-does-not-work-for-eclipse-neon
/*-----------------------------------分割线--------------------------------------*/
关于连接池和数据库异步驱动:
https://juejin.im/post/58fa9d1d0ce4630061200774
https://segmentfault.com/a/1190000016196693
https://github.com/ScalaCool/scalacool.github.io/issues/27
https://blog.csdn.net/Jay_1989/article/details/55188962
http://www.voidcn.com/article/p-zinvdzig-ke.html
- 点赞
- 收藏
- 关注作者
评论(0)