首页 星云 工具 资源 星选 资讯 热门工具
:

PDF转图片 完全免费 小红书视频下载 无水印 抖音视频下载 无水印 数字星空

reactor demo

后端 63.73KB 26 需要积分: 1
立即下载

资源介绍:

reactor demo
package com.atguigu.reactor; import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.core.publisher.Sinks; import reactor.core.scheduler.Schedulers; import reactor.util.context.Context; import java.io.IOException; import java.time.Duration; import java.util.List; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Stream; /** * @author lfy * @Description * @create 2023-11-30 20:07 */ public class APITest { @Test void next(){ Integer block = Flux.just(1, 2, 3) .next() .block(); System.out.println(block); } //Context-API: https://projectreactor.io/docs/core/release/reference/#context @Test //ThreadLocal在响应式编程中无法使用。 //响应式中,数据流期间共享数据,Context API: Context:读写 ContextView:只读; void threadlocal(){ //支持Context的中间操作 Flux.just(1,2,3) .transformDeferredContextual((flux,context)->{ System.out.println("flux = " + flux); System.out.println("context = " + context); return flux.map(i->i+"==>"+context.get("prefix")); }) //上游能拿到下游的最近一次数据 .contextWrite(Context.of("prefix","哈哈")) //ThreadLocal共享了数据,上游的所有人能看到; Context由下游传播给上游 .subscribe(v-> System.out.println("v = " + v)); //以前 命令式编程 // controller -- service -- dao //响应式编程 dao(10:数据源) --> service(10) --> controller(10); 从下游反向传播 } @Test void paralleFlux() throws IOException { // 百万数据,8个线程,每个线程处理100,进行分批处理一直处理结束 Flux.range(1,1000000) .buffer(100) .parallel(8) .runOn(Schedulers.newParallel("yy")) .log() .flatMap(list->Flux.fromIterable(list)) .collectSortedList(Integer::compareTo) .subscribe(v-> System.out.println("v = " + v)); System.in.read(); } @Test void block(){ // // Integer integer = Flux.just(1, 2, 4) // .map(i -> i + 10) // .blockLast(); // System.out.println(integer); List integers = Flux.just(1, 2, 4) .map(i -> i + 10) .collectList() .block(); // 也是一种订阅者; BlockingMonoSubscriber System.out.println("integers = " + integers); } @Test void sinks() throws InterruptedException, IOException { // Flux.create(fluxSink -> { // fluxSink.next("111") // }) // Sinks.many(); //发送Flux数据。 // Sinks.one(); //发送Mono数据 // Sinks: 接受器,数据管道,所有数据顺着这个管道往下走的 //Sinks.many().unicast(); //单播: 这个管道只能绑定单个订阅者(消费者) //Sinks.many().multicast();//多播: 这个管道能绑定多个订阅者 //Sinks.many().replay();//重放: 这个管道能重放元素。 是否给后来的订阅者把之前的元素依然发给它; // 从头消费还是从订阅的那一刻消费; // Sinks.Many many = Sinks.many() // .multicast() //多播 // .onBackpressureBuffer(); //背压队列 //默认订阅者,从订阅的那一刻开始接元素 //发布者数据重放; 底层利用队列进行缓存之前数据 // Sinks.Many many = Sinks.many().replay().limit(3); // // new Thread(()->{ // for (int i = 0; i < 10; i++) { // many.tryEmitNext("a-"+i); // try { // Thread.sleep(1000); // } catch (InterruptedException e) { // throw new RuntimeException(e); // } // } // }).start(); // // // // //订阅 // many.asFlux().subscribe(v-> System.out.println("v1 = " + v)); // // new Thread(()->{ // try { // Thread.sleep(5000); // } catch (InterruptedException e) { // throw new RuntimeException(e); // } // many.asFlux().subscribe(v-> System.out.println("v2 = " + v)); // }).start(); Flux cache = Flux.range(1, 10) .delayElements(Duration.ofSeconds(1)) //不调缓存默认就是缓存所有 .cache(1); //缓存两个元素; 默认全部缓存 cache.subscribe();//缓存元素; // 最定义订阅者 new Thread(()->{ try { Thread.sleep(5000); } catch (InterruptedException e) { throw new RuntimeException(e); } cache.subscribe(v-> System.out.println("v = " + v)); }).start(); System.in.read(); } @Test void retryAndTimeout() throws IOException { Flux.just(1) .delayElements(Duration.ofSeconds(3)) .log() .timeout(Duration.ofSeconds(2)) .retry(2) // 把流从头到尾重新请求一次 .onErrorReturn(2) .map(i-> i+"haha") .subscribe(v-> System.out.println("v = " + v)); System.in.read(); } void createOrder() { //1、校验订单;价格有问题; // 只需要敲正确的业务代码,所有的业务异常,全部抛出我们自定义异常,由全局异常处理器进行统一处理 // throw new GmallException(ResultCodeEnum.ORDER_PRICE_INVAILID); } // 默认:错误是一种中断行为; // subscribe: 消费者可以感知 正常元素try 与 流发生的错误catch ; // 更多的错误处理: // java 错误处理 @Test void error() throws IOException { // Flux.just(1, 2, 0, 4) // .map(i -> "100 / " + i + " = " + (100 / i)) // .onErrorReturn(NullPointerException.class,"哈哈-6666") // .subscribe(v-> System.out.println("v = " + v), // err -> System.out.println("err = " + err), // ()-> System.out.println("流结束")); // error handling example // // Flux.just(1, 2, 0, 4) // .map(i -> "100 / " + i + " = " + (100 / i)) // .onErrorResume(err -> hahaha(err)) // .subscribe(v -> System.out.println("v = " + v), // err -> System.out.println("err = " + err), // () -> System.out.println("流结束")); // Flux.just(1, 2, 0, 4) // .map(i -> "100 / " + i + " = " + (100 / i)) // .onErrorResume(err -> Flux.error(new BusinessException(err.getMessage()+":炸了"))) // Flux.just(1, 2, 0, 4) // .map(i -> "100 / " + i + " = " + (100 / i)) // .onErrorMap(err-> new BusinessException(err.getMessage()+": 又炸了...")) // .subscribe(v -> System.out.println("v = " + v), // err -> System.out.println("err = " + err), // () -> System.out.println("流结束")); // Flux.just(1, 2, 3, 4) // .map(i -> "100 / " + i + " = " + (100 / i)) // .doOnError(err -> { // System.out.println("err已被记录 = " + err); // }) // .doFinally(signalType -> { // System.out.println("流信号:"+signalType); // }) // .subscribe(v -> System.out.println("v = " + v), //

资源文件列表:

reactor-programming-master.zip 大约有118个文件
  1. reactor-programming-master/
  2. reactor-programming-master/.gitignore 16B
  3. reactor-programming-master/chapter01-stream/
  4. reactor-programming-master/chapter01-stream/pom.xml 961B
  5. reactor-programming-master/chapter01-stream/src/
  6. reactor-programming-master/chapter01-stream/src/main/
  7. reactor-programming-master/chapter01-stream/src/main/java/
  8. reactor-programming-master/chapter01-stream/src/main/java/com/
  9. reactor-programming-master/chapter01-stream/src/main/java/com/atguigu/
  10. reactor-programming-master/chapter01-stream/src/main/java/com/atguigu/flow/
  11. reactor-programming-master/chapter01-stream/src/main/java/com/atguigu/flow/FlowDemo.java 4.53KB
  12. reactor-programming-master/chapter01-stream/src/main/java/com/atguigu/lambda/
  13. reactor-programming-master/chapter01-stream/src/main/java/com/atguigu/lambda/FunctionDemo.java 1.85KB
  14. reactor-programming-master/chapter01-stream/src/main/java/com/atguigu/lambda/Lambda.java 4.53KB
  15. reactor-programming-master/chapter01-stream/src/main/java/com/atguigu/lambda/StreamDemo.java 8.25KB
  16. reactor-programming-master/chapter02-reactor/
  17. reactor-programming-master/chapter02-reactor/pom.xml 1.66KB
  18. reactor-programming-master/chapter02-reactor/src/
  19. reactor-programming-master/chapter02-reactor/src/main/
  20. reactor-programming-master/chapter02-reactor/src/main/java/
  21. reactor-programming-master/chapter02-reactor/src/main/java/com/
  22. reactor-programming-master/chapter02-reactor/src/main/java/com/atguigu/
  23. reactor-programming-master/chapter02-reactor/src/main/java/com/atguigu/reactor/
  24. reactor-programming-master/chapter02-reactor/src/main/java/com/atguigu/reactor/FluxDemo.java 6.76KB
  25. reactor-programming-master/chapter02-reactor/src/test/
  26. reactor-programming-master/chapter02-reactor/src/test/java/
  27. reactor-programming-master/chapter02-reactor/src/test/java/com/
  28. reactor-programming-master/chapter02-reactor/src/test/java/com/atguigu/
  29. reactor-programming-master/chapter02-reactor/src/test/java/com/atguigu/reactor/
  30. reactor-programming-master/chapter02-reactor/src/test/java/com/atguigu/reactor/APITest.java 14.47KB
  31. reactor-programming-master/chapter03-webflux/
  32. reactor-programming-master/chapter03-webflux/pom.xml 951B
  33. reactor-programming-master/chapter03-webflux/src/
  34. reactor-programming-master/chapter03-webflux/src/main/
  35. reactor-programming-master/chapter03-webflux/src/main/java/
  36. reactor-programming-master/chapter03-webflux/src/main/java/com/
  37. reactor-programming-master/chapter03-webflux/src/main/java/com/atguigu/
  38. reactor-programming-master/chapter03-webflux/src/main/java/com/atguigu/webflux/
  39. reactor-programming-master/chapter03-webflux/src/main/java/com/atguigu/webflux/FluxMainApplication.java 2.58KB
  40. reactor-programming-master/chapter03-webflux/src/main/java/com/atguigu/webflux/WebFluxMainApplication.java 705B
  41. reactor-programming-master/chapter03-webflux/src/main/java/com/atguigu/webflux/config/
  42. reactor-programming-master/chapter03-webflux/src/main/java/com/atguigu/webflux/config/MyWebConfiguration.java 823B
  43. reactor-programming-master/chapter03-webflux/src/main/java/com/atguigu/webflux/controller/
  44. reactor-programming-master/chapter03-webflux/src/main/java/com/atguigu/webflux/controller/HelloController.java 3.48KB
  45. reactor-programming-master/chapter03-webflux/src/main/java/com/atguigu/webflux/exception/
  46. reactor-programming-master/chapter03-webflux/src/main/java/com/atguigu/webflux/exception/GlobalExceptionHandler.java 866B
  47. reactor-programming-master/chapter03-webflux/src/main/java/com/atguigu/webflux/filter/
  48. reactor-programming-master/chapter03-webflux/src/main/java/com/atguigu/webflux/filter/MyWebFilter.java 1.37KB
  49. reactor-programming-master/chapter03-webflux/src/main/resources/
  50. reactor-programming-master/chapter03-webflux/src/main/resources/static/
  51. reactor-programming-master/chapter03-webflux/src/main/resources/static/index.html 1.12KB
  52. reactor-programming-master/chapter04-r2dbc/
  53. reactor-programming-master/chapter04-r2dbc/pom.xml 1.75KB
  54. reactor-programming-master/chapter04-r2dbc/src/
  55. reactor-programming-master/chapter04-r2dbc/src/main/
  56. reactor-programming-master/chapter04-r2dbc/src/main/java/
  57. reactor-programming-master/chapter04-r2dbc/src/main/java/com/
  58. reactor-programming-master/chapter04-r2dbc/src/main/java/com/atguigu/
  59. reactor-programming-master/chapter04-r2dbc/src/main/java/com/atguigu/r2dbc/
  60. reactor-programming-master/chapter04-r2dbc/src/main/java/com/atguigu/r2dbc/R2DBCMainApplication.java 1.26KB
  61. reactor-programming-master/chapter04-r2dbc/src/main/java/com/atguigu/r2dbc/config/
  62. reactor-programming-master/chapter04-r2dbc/src/main/java/com/atguigu/r2dbc/config/R2DbcConfiguration.java 1008B
  63. reactor-programming-master/chapter04-r2dbc/src/main/java/com/atguigu/r2dbc/config/converter/
  64. reactor-programming-master/chapter04-r2dbc/src/main/java/com/atguigu/r2dbc/config/converter/BookConverter.java 1.6KB
  65. reactor-programming-master/chapter04-r2dbc/src/main/java/com/atguigu/r2dbc/controller/
  66. reactor-programming-master/chapter04-r2dbc/src/main/java/com/atguigu/r2dbc/controller/AuthorController.java 456B
  67. reactor-programming-master/chapter04-r2dbc/src/main/java/com/atguigu/r2dbc/entity/
  68. reactor-programming-master/chapter04-r2dbc/src/main/java/com/atguigu/r2dbc/entity/TAuthor.java 677B
  69. reactor-programming-master/chapter04-r2dbc/src/main/java/com/atguigu/r2dbc/entity/TBook.java 565B
  70. reactor-programming-master/chapter04-r2dbc/src/main/java/com/atguigu/r2dbc/entity/TBookAuthor.java 544B
  71. reactor-programming-master/chapter04-r2dbc/src/main/java/com/atguigu/r2dbc/repositories/
  72. reactor-programming-master/chapter04-r2dbc/src/main/java/com/atguigu/r2dbc/repositories/AuthorRepositories.java 1.12KB
  73. reactor-programming-master/chapter04-r2dbc/src/main/java/com/atguigu/r2dbc/repositories/BookAuthorRepostory.java 836B
  74. reactor-programming-master/chapter04-r2dbc/src/main/java/com/atguigu/r2dbc/repositories/BookRepostory.java 783B
  75. reactor-programming-master/chapter04-r2dbc/src/main/resources/
  76. reactor-programming-master/chapter04-r2dbc/src/main/resources/application.yaml 171B
  77. reactor-programming-master/chapter04-r2dbc/src/test/
  78. reactor-programming-master/chapter04-r2dbc/src/test/java/
  79. reactor-programming-master/chapter04-r2dbc/src/test/java/com/
  80. reactor-programming-master/chapter04-r2dbc/src/test/java/com/atguigu/
  81. reactor-programming-master/chapter04-r2dbc/src/test/java/com/atguigu/r2dbc/
  82. reactor-programming-master/chapter04-r2dbc/src/test/java/com/atguigu/r2dbc/R2DBCTest.java 11.42KB
  83. reactor-programming-master/chapter05-security/
  84. reactor-programming-master/chapter05-security/pom.xml 1.91KB
  85. reactor-programming-master/chapter05-security/src/
  86. reactor-programming-master/chapter05-security/src/main/
  87. reactor-programming-master/chapter05-security/src/main/java/
  88. reactor-programming-master/chapter05-security/src/main/java/com/
  89. reactor-programming-master/chapter05-security/src/main/java/com/atguigu/
  90. reactor-programming-master/chapter05-security/src/main/java/com/atguigu/security/
  91. reactor-programming-master/chapter05-security/src/main/java/com/atguigu/security/SecurityDemoMainApplicatioin.java 901B
  92. reactor-programming-master/chapter05-security/src/main/java/com/atguigu/security/component/
  93. reactor-programming-master/chapter05-security/src/main/java/com/atguigu/security/component/AppReactiveUserDetailsService.java 2.8KB
  94. reactor-programming-master/chapter05-security/src/main/java/com/atguigu/security/config/
  95. reactor-programming-master/chapter05-security/src/main/java/com/atguigu/security/config/AppR2DBCConfiguration.java 328B
  96. reactor-programming-master/chapter05-security/src/main/java/com/atguigu/security/config/AppSecurityConfiguration.java 3.2KB
  97. reactor-programming-master/chapter05-security/src/main/java/com/atguigu/security/controller/
  98. reactor-programming-master/chapter05-security/src/main/java/com/atguigu/security/controller/HelloController.java 779B
  99. reactor-programming-master/chapter05-security/src/main/java/com/atguigu/security/entity/
  100. reactor-programming-master/chapter05-security/src/main/java/com/atguigu/security/entity/TPerm.java 493B
  101. reactor-programming-master/chapter05-security/src/main/java/com/atguigu/security/entity/TRolePerm.java 468B
  102. reactor-programming-master/chapter05-security/src/main/java/com/atguigu/security/entity/TRoles.java 461B
  103. reactor-programming-master/chapter05-security/src/main/java/com/atguigu/security/entity/TUser.java 521B
  104. reactor-programming-master/chapter05-security/src/main/java/com/atguigu/security/entity/TUserRole.java 467B
  105. reactor-programming-master/chapter05-security/src/main/resources/
  106. reactor-programming-master/chapter05-security/src/main/resources/application.yaml 285B
  107. reactor-programming-master/chapter05-security/src/main/resources/static/
  108. reactor-programming-master/chapter05-security/src/main/resources/static/js/
  109. reactor-programming-master/chapter05-security/src/main/resources/static/js/hello.js 11B
  110. reactor-programming-master/chapter05-security/src/test/
  111. reactor-programming-master/chapter05-security/src/test/java/
  112. reactor-programming-master/chapter05-security/src/test/java/com/
  113. reactor-programming-master/chapter05-security/src/test/java/com/atguigu/
  114. reactor-programming-master/chapter05-security/src/test/java/com/atguigu/security/
  115. reactor-programming-master/chapter05-security/src/test/java/com/atguigu/security/PasswordTest.java 726B
  116. reactor-programming-master/chapter05-security/src/test/java/com/atguigu/test/
  117. reactor-programming-master/chapter05-security/src/test/java/com/atguigu/test/PasswordTest.java 195B
  118. reactor-programming-master/pom.xml 1.08KB
0评论
提交 加载更多评论
其他资源 F4-perfCounter.zip
F4-perfCounter.zip
4BFF881B-5EE2-495C-A7A0-A5818A499374.zip
4BFF881B-5EE2-495C-A7A0-A5818A499374.zip
blender插件hardops
blender插件hardops
黑马头条(day02)资料
需要用到的sql脚本,微服务模块,模板文件
西南交通大学 模拟电子技术课程资料
西南交通大学 模拟电子技术课程PPT
西南交通大学 模拟电子技术课程资料 西南交通大学 模拟电子技术课程资料 西南交通大学 模拟电子技术课程资料
巴比达9.0.8版 免费内网穿透
用于场景: 1、远程桌面控制:你可以将巴比达安装在家里或公司的电脑实现远程桌面,方便远程办公。 2、访问文件共享服务器:通过巴比达,你可以将公司或家里的使用神卓文件管家将文件共享,方便远程访问文件。 3、远程访问公司内网财务系统、进销存系统、ERP系统等:巴比达可以帮助你访问公司内部网络的应用程序,如财务系统、进销存系统、ERP系统等。 4、搭建个人游戏:如果你想将你的游戏服务器,巴比达可以帮助你实现用于固定公网访问地址。 5、远程访问群晖NAS:巴比达可以将群晖NAS的进行绑定,方便远程访问群晖NAS、互传照片、互传视频、文件备份上传等。 6、搭建Web站点:通过巴比达分配一个固定公网地址,可以将本地搭建的Web站点,方便功能测试或给用户远程演示。
巴比达内网穿透、免费内网穿透
无需公网IP、无需设置路由器 用于场景: 1、远程桌面控制:你可以将巴比达安装在家里或公司的电脑实现远程桌面,方便远程办公。 2、访问文件共享服务器:通过巴比达,你可以将公司或家里的使用神卓文件管家将文件共享,方便远程访问文件。 3、远程访问公司内网财务系统、进销存系统、ERP系统等:巴比达可以帮助你访问公司内部网络的应用程序,如财务系统、进销存系统、ERP系统等。 4、搭建个人游戏:如果你想将你的游戏服务器,巴比达可以帮助你实现用于固定公网访问地址。 5、远程访问群晖NAS:巴比达可以将群晖NAS的进行绑定,方便远程访问群晖NAS、互传照片、互传视频、文件备份上传等。 6、搭建Web站点:通过巴比达分配一个固定公网地址,可以将本地搭建的Web站点,方便功能测试或给用户远程演示。 7、远程SSH服务器:通过巴比达,你可以将家里的或公司的主机SSH服务分配一个固定公网地址 ,方便远程管理 liunx系统。
pdf电子发票提取主要内容转excel表格
提取pdf电子发票的主要信息,记录到excel表格内,提取发票信息包括:发票号码、开票日期、购买方名称、购买方税号、销售方名称、销售方税号、项目名称、金额、税率、合计总额。提取两类电子发票格式,