Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 与其他发布者的缓冲-弹簧反应器_Spring_Project Reactor - Fatal编程技术网

Spring 与其他发布者的缓冲-弹簧反应器

Spring 与其他发布者的缓冲-弹簧反应器,spring,project-reactor,Spring,Project Reactor,谁能举例说明Flux.buffer(Publisher other)的工作原理吗?我无法利用其他出版商将原始Flux拆分为多个列表 例: List strings=new ArrayList(); 字符串。添加(“A”); 字符串。添加(“B”); Flux stringFlux=Flux.fromIterable(strings.cache(); 对于(int i=0;i{ 通量.从可数(整数); }).订阅(a->{ 系统输出打印项次(a); }); 这仍然将原始列表打印为输出,而不是将其

谁能举例说明Flux.buffer(Publisher other)的工作原理吗?我无法利用其他出版商将原始Flux拆分为多个列表

例:

List strings=new ArrayList();
字符串。添加(“A”);
字符串。添加(“B”);
Flux stringFlux=Flux.fromIterable(strings.cache();
对于(int i=0;i<100;i++){
字符串。添加(“+i”);
}
列表整数=新的ArrayList(2);
整数。加(1);
整数。加(1);
整数。加(1);
stringFlux.buffer((a)->{
通量.从可数(整数);
}).订阅(a->{
系统输出打印项次(a);
});

这仍然将原始列表打印为输出,而不是将其拆分

带谓词的bufferuntil实际上就是我要找的

    List<String> strings = new ArrayList<>();
    strings.add("A");
    strings.add("B");
    Flux<String> stringFlux = Flux.fromIterable(strings).cache();


    for(int i = 0; i < 100; i++) {
        strings.add(""+i);
    }
    List<Integer> integers = new ArrayList<>(2);
        integers.add(1);
    integers.add(1);
    integers.add(1);

    stringFlux.buffer((a) -> {
        Flux.fromIterable(integers);
    }).subscribe(a -> {
        System.out.println(a);
    });