响应式编程查询记录

举报
Amrf 发表于 2019/11/13 11:21:00 2019/11/13
【摘要】 https://halfrost.com/functional_reactive_programming_concept/https://yq.aliyun.com/articles/639744https://stackoverflow.com/questions/56461260/java-spring-webflux-vs-rxjavahttps://medium.com/mindor...

概念听了很久,文章也浏览了不少,看起来就是异步编程,我更关注怎么应用到当前的一下项目设计中;

下面就试一试,测试项目地址:

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

看到一个评论:

image.png

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://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html#webflux-reactive-spring-web

https://stackoverflow.com/questions/51160076/spring-5-webflux-mono-and-flux

https://stackoverflow.com/questions/45240005/how-to-log-request-and-response-bodies-in-spring-webflux

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();
    }
}

差别没多大,只不过一种写法看习惯后,突然看另一种写法会比较不适应而已;

参考:

https://stackoverflow.com/questions/25242321/difference-between-spring-controller-and-restcontroller-annotation

https://stackoverflow.com/questions/39077787/difference-between-the-annotations-getmapping-and-requestmappingmethod-requ

https://javarevisited.blogspot.com/2017/08/difference-between-restcontroller-and-controller-annotations-spring-mvc-rest.html

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://stackoverflow.com/questions/45115312/rxjs-rx-net-observable-subscribe-vs-async-await/45117113

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://docs.spring.io/spring-framework/docs/5.0.0.BUILD-SNAPSHOT/spring-framework-reference/html/web-reactive.html

/*----------------------------分割线-------------------------------------*/

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

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/luis-moral/sample-webflux-http-netty/tree/master/src/main/java/sample/webflux/http/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://www.v2ex.com/t/484299

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

https://blog.csdn.net/xuz0917/article/details/79428467

https://blog.csdn.net/qq_18433441/article/details/53635798

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。