{"id":502,"date":"2023-11-03T15:05:19","date_gmt":"2023-11-03T07:05:19","guid":{"rendered":"https:\/\/www.talktop.cn\/?p=502"},"modified":"2024-12-30T09:34:29","modified_gmt":"2024-12-30T01:34:29","slug":"%e5%93%8d%e5%ba%94%e5%bc%8f%e7%bc%96%e7%a8%8bspringwebflux%e8%bf%9b%e9%98%b6%e7%af%87","status":"publish","type":"post","link":"https:\/\/www.talktop.cn\/?p=502","title":{"rendered":"\u54cd\u5e94\u5f0f\u7f16\u7a0bSpring WebFlux \u8fdb\u9636\u7bc7"},"content":{"rendered":"\n<p>\u7ee7\u57fa\u7840\u7bc7\u4e4b\u540e\uff0c\u672c\u7bc7\u6587\u7ae0\u5c06\u6df1\u5165\u63a2\u8ba8Spring WebFlux\u7684\u8fdb\u9636\u7279\u6027\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u5728\u6784\u5efa\u54cd\u5e94\u5f0f\u5e94\u7528\u65f6\u80fd\u591f\u66f4\u597d\u5730\u7ba1\u7406\u590d\u6742\u573a\u666f\u548c\u63d0\u5347\u6027\u80fd\u3002<\/p>\n\n\n\n<p><strong>\u4e00\u3001\u8fdb\u9636\u7279\u6027<\/strong><\/p>\n\n\n\n<p><strong>\u9519\u8bef\u5904\u7406\u7b56\u7565<\/strong><\/p>\n\n\n\n<p>\u6d41\u7a0b\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img fetchpriority=\"high\" decoding=\"async\" width=\"988\" height=\"771\" src=\"https:\/\/www.talktop.cn\/wp-content\/uploads\/2023\/11\/image-6.png\" alt=\"\" class=\"wp-image-503\" style=\"width:700px\" srcset=\"https:\/\/www.talktop.cn\/wp-content\/uploads\/2023\/11\/image-6.png 988w, https:\/\/www.talktop.cn\/wp-content\/uploads\/2023\/11\/image-6-300x234.png 300w, https:\/\/www.talktop.cn\/wp-content\/uploads\/2023\/11\/image-6-768x599.png 768w\" sizes=\"(max-width: 988px) 100vw, 988px\" \/><\/figure>\n\n\n\n<p><br>\u54cd\u5e94\u5f0f\u6d41\u4e2d\u7684\u9519\u8bef\u5904\u7406\u662f\u81f3\u5173\u91cd\u8981\u7684\u3002Spring WebFlux\u63d0\u4f9b\u4e86\u591a\u79cd\u9519\u8bef\u5904\u7406\u673a\u5236\uff0c\u5982onErrorReturn, onErrorResume, \u548conErrorMap\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background\"><code>import reactor.core.publisher.Flux;\nimport reactor.core.publisher.Mono;\n\npublic class ErrorHandlingExample {\n\n    public static void main(String&#91;] args) {\n        \/\/ \u521b\u5efa\u4e00\u4e2a\u5305\u542b\u9519\u8bef\u7684Flux\u5e8f\u5217\n        Flux&lt;String&gt; fluxWithError = Flux.just(\"A\", \"B\", \"C\")\n                \/\/ \u5728\u5e8f\u5217\u4e2d\u5f15\u5165\u4e00\u4e2a\u9519\u8bef\n                .concatWith(Mono.error(new RuntimeException(\"Unexpected Error\")))\n                \/\/ \u4f7f\u7528onErrorReturn\u64cd\u4f5c\u7b26\u6765\u5904\u7406\u9519\u8bef\uff0c\u8fd4\u56de\u4e00\u4e2a\u9ed8\u8ba4\u503c\n                .onErrorReturn(\"Default\");\n\n        \/\/ \u8ba2\u9605\u5e76\u5904\u7406\u53ef\u80fd\u5305\u542b\u9519\u8bef\u7684Flux\n        fluxWithError.subscribe(\n                value -&gt; System.out.println(\"Received: \" + value),\n                error -&gt; System.out.println(\"Error: \" + error.getMessage()),\n                () -&gt; System.out.println(\"Completed successfully\")\n        );\n\n        \/\/ \u521b\u5efa\u53e6\u4e00\u4e2a\u5305\u542b\u9519\u8bef\u7684Flux\u5e8f\u5217\n        Flux&lt;String&gt; fluxWithResume = Flux.just(\"1\", \"2\", \"error\", \"3\")\n                \/\/ \u4f7f\u7528flatMap\u6765\u5904\u7406\u6bcf\u4e2a\u5143\u7d20\n                .flatMap(value -&gt; {\n                    if (\"error\".equals(value)) {\n                        \/\/ \u5f53\u9047\u5230\"error\"\u5b57\u7b26\u4e32\u65f6\uff0c\u629b\u51fa\u5f02\u5e38\n                        return Mono.error(new IllegalStateException(\"Error occurred\"));\n                    } else {\n                        \/\/ \u5176\u4ed6\u60c5\u51b5\u4e0b\uff0c\u6b63\u5e38\u8fd4\u56de\u503c\n                        return Mono.just(value);\n                    }\n                })\n                \/\/ \u4f7f\u7528onErrorResume\u6765\u63d0\u4f9b\u4e00\u4e2a\u66ff\u4ee3\u7684Flux\n                .onErrorResume(e -&gt; {\n                    if (e instanceof IllegalStateException) {\n                        \/\/ \u5982\u679c\u9519\u8bef\u662fIllegalStateException\uff0c\u8fd4\u56de\u4e00\u4e2a\u5305\u542b\u66ff\u4ee3\u503c\u7684Flux\n                        return Flux.just(\"Recovered\");\n                    } else {\n                        \/\/ \u5176\u4ed6\u7c7b\u578b\u7684\u9519\u8bef\uff0c\u91cd\u65b0\u629b\u51fa\n                        return Flux.error(e);\n                    }\n                });\n\n        \/\/ \u8ba2\u9605\u5e76\u5904\u7406\u53ef\u80fd\u5305\u542b\u9519\u8bef\u7684Flux\n        fluxWithResume.subscribe(\n                value -&gt; System.out.println(\"Received: \" + value),\n                error -&gt; System.out.println(\"Error: \" + error.getMessage()),\n                () -&gt; System.out.println(\"Completed successfully\")\n        );\n\n        \/\/ \u521b\u5efa\u4e00\u4e2a\u5305\u542b\u9519\u8bef\u7684Mono\u5e8f\u5217\n        Mono&lt;String&gt; monoWithErrorMap = Mono.just(\"test\")\n                \/\/ \u6a21\u62df\u4e00\u4e2a\u64cd\u4f5c\uff0c\u8be5\u64cd\u4f5c\u53ef\u80fd\u4f1a\u629b\u51fa\u5f02\u5e38\n                .map(value -&gt; {\n                    if (\"test\".equals(value)) {\n                        throw new RuntimeException(\"Test error\");\n                    }\n                    return value;\n                })\n                \/\/ \u4f7f\u7528onErrorMap\u6765\u8f6c\u6362\u9519\u8bef\n                .onErrorMap(original -&gt; new CustomException(\"Custom error message\", original));\n\n        \/\/ \u8ba2\u9605\u5e76\u5904\u7406\u53ef\u80fd\u5305\u542b\u9519\u8bef\u7684Mono\n        monoWithErrorMap.subscribe(\n                value -&gt; System.out.println(\"Received: \" + value),\n                error -&gt; {\n                    if (error instanceof CustomException) {\n                        System.out.println(\"Custom Error: \" + error.getMessage());\n                    } else {\n                        System.out.println(\"Error: \" + error.getMessage());\n                    }\n                },\n                () -&gt; System.out.println(\"Completed successfully\")\n        );\n    }\n\n    \/\/ \u81ea\u5b9a\u4e49\u5f02\u5e38\u7c7b\n    static class CustomException extends RuntimeException {\n        public CustomException(String message, Throwable cause) {\n            super(message, cause);\n        }\n    }\n}<\/code><\/pre>\n\n\n\n<p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e09\u4e2a\u4e0d\u540c\u7684\u54cd\u5e94\u5f0f\u6d41\uff0c\u6bcf\u4e2a\u6d41\u90fd\u4ee5\u4e0d\u540c\u7684\u65b9\u5f0f\u5904\u7406\u9519\u8bef\uff1a<\/p>\n\n\n\n<p><code>fluxWithError<\/code> \u4f7f\u7528 <code>onErrorReturn<\/code> \u6765\u8fd4\u56de\u4e00\u4e2a\u9ed8\u8ba4\u503c\uff0c\u5f53\u6d41\u4e2d\u53d1\u751f\u9519\u8bef\u65f6\u3002<\/p>\n\n\n\n<p><code>fluxWithResume<\/code> \u4f7f\u7528 <code>onErrorResume<\/code> \u6765\u63d0\u4f9b\u4e00\u4e2a\u66ff\u4ee3\u7684\u6d41\uff0c\u8fd9\u4e2a\u66ff\u4ee3\u7684\u6d41\u4f1a\u5728\u539f\u59cb\u6d41\u53d1\u751f\u7279\u5b9a\u7c7b\u578b\u9519\u8bef\u65f6\u53d1\u51fa\u4e00\u4e2a\u6062\u590d\u503c\u3002<\/p>\n\n\n\n<p><code>monoWithErrorMap<\/code> \u4f7f\u7528 <code>onErrorMap<\/code> \u6765\u8f6c\u6362\u9519\u8bef\uff0c\u5c06\u539f\u59cb\u9519\u8bef\u6620\u5c04\u4e3a\u4e00\u4e2a\u81ea\u5b9a\u4e49\u5f02\u5e38\u3002<\/p>\n\n\n\n<p>\u6bcf\u4e2a\u6d41\u90fd\u901a\u8fc7<code>subscribe<\/code>\u65b9\u6cd5\u8fdb\u884c\u8ba2\u9605\uff0c\u5e76\u63d0\u4f9b\u4e86\u5bf9\u5e94\u7684\u5904\u7406\u903b\u8f91\u3002\u8fd9\u4e9b\u793a\u4f8b\u5c55\u793a\u4e86\u5982\u4f55\u5728\u54cd\u5e94\u5f0f\u6d41\u4e2d\u4f18\u96c5\u5730\u5904\u7406\u9519\u8bef\u60c5\u51b5\u3002<\/p>\n\n\n\n<p><strong>\u8c03\u5ea6\u5668\u548c\u7ebf\u7a0b\u6a21\u578b<\/strong><br>Spring WebFlux\u5141\u8bb8\u4f60\u901a\u8fc7\u8c03\u5ea6\u5668\uff08Schedulers\uff09\u6765\u63a7\u5236\u6267\u884c\u64cd\u4f5c\u7684\u7ebf\u7a0b\uff0c\u8fd9\u5bf9\u4e8e\u7ba1\u7406\u5f02\u6b65\u4efb\u52a1\u7684\u6267\u884c\u975e\u5e38\u91cd\u8981\u3002<\/p>\n\n\n\n<p>\u8c03\u5ea6\u5668\u5b9a\u4e49\u4e86\u54cd\u5e94\u5f0f\u6d41\u64cd\u4f5c\u6267\u884c\u7684\u4e0a\u4e0b\u6587\uff0c\u5373\u5728\u54ea\u4e2a\u7ebf\u7a0b\u6216\u7ebf\u7a0b\u6c60\u4e0a\u6267\u884c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background\"><code>import reactor.core.publisher.Flux;\nimport reactor.core.scheduler.Schedulers;\n\npublic class SchedulerExample {\n\n    public static void main(String&#91;] args) {\n        \/\/ \u521b\u5efa\u4e00\u4e2aFlux\u5e8f\u5217\n        Flux&lt;String&gt; flux = Flux.just(\"A\", \"B\", \"C\", \"D\")\n                \/\/ \u6307\u5b9a\u4e00\u4e2a\u8c03\u5ea6\u5668\uff0c\u8be5\u8c03\u5ea6\u5668\u4f7f\u7528\u4e00\u4e2a\u5f39\u6027\u7684\u7ebf\u7a0b\u6c60\u6765\u8fd0\u884c\u6d41\u7684\u5904\u7406\n                \/\/ \u5f39\u6027\u7ebf\u7a0b\u6c60\u9002\u7528\u4e8eI\/O\u64cd\u4f5c\u6216\u5176\u4ed6\u963b\u585e\u64cd\u4f5c\uff0c\u56e0\u4e3a\u5b83\u53ef\u4ee5\u6839\u636e\u9700\u8981\u521b\u5efa\u65b0\u7684\u7ebf\u7a0b\n                .subscribeOn(Schedulers.boundedElastic())\n                \/\/ map\u64cd\u4f5c\u5c06\u5728\u5f39\u6027\u7ebf\u7a0b\u6c60\u4e2d\u6267\u884c\uff0c\u56e0\u4e3a\u5b83\u4f4d\u4e8esubscribeOn\u4e4b\u540e\n                .map(value -&gt; {\n                    \/\/ \u6a21\u62df\u8017\u65f6\u7684\u64cd\u4f5c\uff0c\u4f8b\u5982\u6570\u636e\u5e93\u8c03\u7528\n                    simulateExpensiveOperation(value);\n                    return value.toLowerCase();\n                });\n\n        \/\/ \u8ba2\u9605\u5e76\u5904\u7406\u6d41\n        flux.subscribe(value -&gt; {\n            \/\/ \u6253\u5370\u7ebf\u7a0b\u4fe1\u606f\u548c\u5904\u7406\u540e\u7684\u503c\n            \/\/ \u8ba2\u9605\u8005\u9ed8\u8ba4\u5728\u53d1\u5e03\u8005\u7684\u7ebf\u7a0b\u4e2d\u6267\u884c\uff0c\u9664\u975e\u4f7f\u7528publishOn\u6307\u5b9a\u5176\u4ed6\u8c03\u5ea6\u5668\n            System.out.println(Thread.currentThread().getName() + \" -&gt; \" + value);\n        });\n\n        \/\/ \u7531\u4e8e\u4e0a\u9762\u7684\u64cd\u4f5c\u662f\u5f02\u6b65\u7684\uff0c\u8fd9\u91cc\u7a0d\u4f5c\u7b49\u5f85\uff0c\u4ee5\u4fbf\u89c2\u5bdf\u8f93\u51fa\n        \/\/ \u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u901a\u5e38\u4e0d\u9700\u8981\u8fd9\u6837\u505a\uff0c\u56e0\u4e3aSpring\u4f1a\u7ba1\u7406\u6d41\u7684\u751f\u547d\u5468\u671f\n        try {\n            Thread.sleep(2000);\n        } catch (InterruptedException e) {\n            Thread.currentThread().interrupt();\n        }\n    }\n\n    private static void simulateExpensiveOperation(String value) {\n        try {\n            \/\/ \u5047\u8bbe\u8fd9\u662f\u4e00\u4e2a\u8017\u65f6\u7684\u64cd\u4f5c\uff0c\u4f8b\u5982\u8fdc\u7a0b\u670d\u52a1\u8c03\u7528\u6216\u6570\u636e\u5e93\u64cd\u4f5c\n            Thread.sleep(1000);\n            System.out.println(\"Processing \" + value + \" on thread \" + Thread.currentThread().getName());\n        } catch (InterruptedException e) {\n            Thread.currentThread().interrupt();\n        }\n    }\n}<\/code><\/pre>\n\n\n\n<p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a\u5305\u542b\u56db\u4e2a\u5b57\u7b26\u4e32\u7684<code>Flux<\/code>\u5e8f\u5217\u3002\u6211\u4eec\u4f7f\u7528<code>subscribeOn(Schedulers.boundedElastic())<\/code>\u6765\u6307\u5b9a\u6574\u4e2a\u6d41\u7684\u5904\u7406\u5e94\u8be5\u5728\u4e00\u4e2a\u5f39\u6027\u7684\u7ebf\u7a0b\u6c60\u4e2d\u6267\u884c\u3002\u8fd9\u4e2a\u7ebf\u7a0b\u6c60\u9002\u5408\u6267\u884c\u963b\u585e\u64cd\u4f5c\uff0c\u56e0\u4e3a\u5b83\u53ef\u4ee5\u6839\u636e\u9700\u8981\u52a8\u6001\u5730\u521b\u5efa\u548c\u9500\u6bc1\u7ebf\u7a0b\u3002<\/p>\n\n\n\n<p><code>map<\/code>\u64cd\u4f5c\u7b26\u7528\u4e8e\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5c0f\u5199\uff0c\u5b83\u4f1a\u5728\u5f39\u6027\u7ebf\u7a0b\u6c60\u4e2d\u6267\u884c\uff0c\u56e0\u4e3a\u5b83\u4f4d\u4e8e<code>subscribeOn<\/code>\u4e4b\u540e\u3002\u6700\u540e\uff0c\u6211\u4eec\u8ba2\u9605\u4e86\u8fd9\u4e2a\u6d41\uff0c\u5e76\u6253\u5370\u51fa\u6bcf\u4e2a\u5904\u7406\u540e\u7684\u503c\u4ee5\u53ca\u6267\u884c\u8be5\u64cd\u4f5c\u7684\u7ebf\u7a0b\u4fe1\u606f\u3002<\/p>\n\n\n\n<p><strong>\u8bf7\u6c42\u5408\u5e76<\/strong><br>\u4f7f\u7528zip\u548ccombineLatest\u7b49\u64cd\u4f5c\u7b26\uff0c\u53ef\u4ee5\u5c06\u591a\u4e2a\u8bf7\u6c42\u7684\u7ed3\u679c\u5408\u5e76\u8d77\u6765\uff0c\u8fd9\u5728\u5904\u7406\u591a\u4e2a\u4f9d\u8d56\u7684\u5f02\u6b65\u64cd\u4f5c\u65f6\u975e\u5e38\u6709\u7528\u3002<\/p>\n\n\n\n<p>\u8bf7\u6c42\u5408\u5e76\u662f\u5c06\u591a\u4e2a\u5f02\u6b65\u64cd\u4f5c\u7684\u7ed3\u679c\u7ec4\u5408\u5728\u4e00\u8d77\uff0c\u5f62\u6210\u4e00\u4e2a\u534f\u8c03\u7684\u54cd\u5e94\u3002<\/p>\n\n\n\n<p><code>zip<\/code>\u64cd\u4f5c\u7b26\u7b49\u5f85\u6240\u6709\u6e90Mono\/Flux\u53d1\u51fa\u4e00\u4e2a\u5143\u7d20\uff0c\u5e76\u4f7f\u7528\u63d0\u4f9b\u7684\u51fd\u6570\u5c06\u8fd9\u4e9b\u5143\u7d20\u7ec4\u5408\u8d77\u6765\u3002<code>combineLatest<\/code>\u5219\u5728\u4efb\u4f55\u4e00\u4e2a\u6e90\u53d1\u51fa\u5143\u7d20\u65f6\uff0c\u4f7f\u7528\u6700\u65b0\u53d1\u51fa\u7684\u5143\u7d20\u8fdb\u884c\u7ec4\u5408\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background\"><code>import reactor.core.publisher.Flux;\nimport reactor.core.publisher.Mono;\nimport reactor.util.function.Tuple2;\n\npublic class RequestCombiningExample {\n\n    public static void main(String&#91;] args) {\n        \/\/ \u6a21\u62df\u4e24\u4e2a\u5f02\u6b65\u6570\u636e\u6e90\u7684\u8bf7\u6c42\n        Mono&lt;String&gt; mono1 = Mono.just(\"Data from Service 1\").delayElement(Duration.ofSeconds(1));\n        Mono&lt;String&gt; mono2 = Mono.just(\"Data from Service 2\").delayElement(Duration.ofSeconds(2));\n\n        \/\/ \u4f7f\u7528zip\u64cd\u4f5c\u7b26\u5408\u5e76\u4e24\u4e2aMono\u7684\u7ed3\u679c\n        Mono&lt;Tuple2&lt;String, String&gt;&gt; combinedMono = Mono.zip(mono1, mono2);\n\n        \/\/ \u8ba2\u9605\u5408\u5e76\u540e\u7684Mono\u5e76\u5904\u7406\u7ed3\u679c\n        combinedMono.subscribe(combinedResult -&gt; {\n            \/\/ combinedResult\u662f\u4e00\u4e2aTuple\uff0c\u5305\u542b\u4e24\u4e2aMono\u7684\u7ed3\u679c\n            String service1Result = combinedResult.getT1();\n            String service2Result = combinedResult.getT2();\n            \/\/ \u6253\u5370\u5408\u5e76\u540e\u7684\u7ed3\u679c\n            System.out.println(\"Combined result: \" + service1Result + \" &amp; \" + service2Result);\n        });\n\n        \/\/ \u7531\u4e8e\u4e0a\u9762\u7684\u64cd\u4f5c\u662f\u5f02\u6b65\u7684\uff0c\u8fd9\u91cc\u7a0d\u4f5c\u7b49\u5f85\uff0c\u4ee5\u4fbf\u89c2\u5bdf\u8f93\u51fa\n        \/\/ \u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u901a\u5e38\u4e0d\u9700\u8981\u8fd9\u6837\u505a\uff0c\u56e0\u4e3aSpring\u4f1a\u7ba1\u7406\u6d41\u7684\u751f\u547d\u5468\u671f\n        try {\n            Thread.sleep(3000);\n        } catch (InterruptedException e) {\n            Thread.currentThread().interrupt();\n        }\n    }\n}<\/code><\/pre>\n\n\n\n<p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e24\u4e2a<code>Mono<\/code>\u5bf9\u8c61\uff0c\u5206\u522b\u6a21\u62df\u4e24\u4e2a\u670d\u52a1\u7684\u5f02\u6b65\u54cd\u5e94\u3002\u6bcf\u4e2a<code>Mono<\/code>\u90fd\u4f7f\u7528<code>delayElement<\/code>\u6765\u6a21\u62df\u7f51\u7edc\u5ef6\u8fdf\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u4f7f\u7528<code>Mono.zip<\/code>\u64cd\u4f5c\u7b26\u6765\u5408\u5e76\u8fd9\u4e24\u4e2a<code>Mono<\/code>\u7684\u7ed3\u679c\u3002<code>zip<\/code>\u64cd\u4f5c\u7b26\u4f1a\u7b49\u5f85\u6240\u6709\u53c2\u4e0e\u5408\u5e76\u7684<code>Mono<\/code>\u90fd\u53d1\u51fa\u5143\u7d20\u540e\uff0c\u624d\u4f1a\u53d1\u51fa\u4e00\u4e2a\u5305\u542b\u6240\u6709\u7ed3\u679c\u7684<code>Tuple<\/code>\u3002<\/p>\n\n\n\n<p>\u7136\u540e\u6211\u4eec\u8ba2\u9605\u5408\u5e76\u540e\u7684<code>Mono<\/code>\u5e76\u5904\u7406\u7ed3\u679c\u3002\u5728\u8fd9\u91cc\uff0c\u6211\u4eec\u4ece<code>Tuple<\/code>\u4e2d\u63d0\u53d6\u6bcf\u4e2a\u670d\u52a1\u7684\u7ed3\u679c\uff0c\u5e76\u5c06\u5b83\u4eec\u6253\u5370\u51fa\u6765\u3002<\/p>\n\n\n\n<p>\u6700\u540e\uff0c\u6211\u4eec\u4f7f\u7528<code>Thread.sleep(3000)<\/code>\u6765\u7b49\u5f85\u5f02\u6b65\u64cd\u4f5c\u5b8c\u6210\u3002\u8fd9\u662f\u4e3a\u4e86\u6f14\u793a\u76ee\u7684\uff0c\u5728\u5b9e\u9645\u7684Spring WebFlux\u5e94\u7528\u4e2d\uff0c\u4f60\u901a\u5e38\u4e0d\u9700\u8981\u8fd9\u6837\u505a\uff0c\u56e0\u4e3aSpring\u7684\u54cd\u5e94\u5f0f\u6846\u67b6\u4f1a\u5904\u7406\u8fd9\u4e9b\u5f02\u6b65\u6d41\u7684\u751f\u547d\u5468\u671f\u3002<\/p>\n\n\n\n<p>\u901a\u8fc7\u672c\u7bc7\u6587\u7ae0\uff0c\u6211\u4eec\u4e86\u89e3\u4e86Spring WebFlux\u7684\u4e00\u4e9b\u8fdb\u9636\u7279\u6027\uff0c\u5305\u62ec\u9519\u8bef\u5904\u7406\u3001\u7ebf\u7a0b\u6a21\u578b\u3001\u8bf7\u6c42\u5408\u5e76\u4ee5\u53ca\u54cd\u5e94\u5f0f\u6d41\u7684\u8f6c\u6362\u548c\u80cc\u538b\u63a7\u5236\u3002\u8fd9\u4e9b\u7279\u6027\u4e3a\u6784\u5efa\u9ad8\u6548\u3001\u5065\u58ee\u7684\u54cd\u5e94\u5f0f\u5e94\u7528\u63d0\u4f9b\u4e86\u66f4\u591a\u7684\u53ef\u80fd\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7ee7\u57fa\u7840\u7bc7\u4e4b\u540e\uff0c\u672c\u7bc7\u6587\u7ae0\u5c06\u6df1\u5165\u63a2\u8ba8Spring WebFlux\u7684\u8fdb\u9636\u7279\u6027\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u5728\u6784\u5efa\u54cd\u5e94\u5f0f\u5e94\u7528\u65f6\u80fd\u591f\u66f4\u597d\u5730 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[118,59],"tags":[37],"class_list":["post-502","post","type-post","status-publish","format-standard","hentry","category-118","category-59","tag-webflux"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u54cd\u5e94\u5f0f\u7f16\u7a0bSpring WebFlux \u8fdb\u9636\u7bc7<\/title>\n<meta name=\"description\" content=\"\u901a\u8fc7\u672c\u7bc7\u6587\u7ae0\uff0c\u6211\u4eec\u4e86\u89e3\u4e86Spring WebFlux\u7684\u4e00\u4e9b\u8fdb\u9636\u7279\u6027\uff0c\u5305\u62ec\u9519\u8bef\u5904\u7406\u3001\u7ebf\u7a0b\u6a21\u578b\u3001\u8bf7\u6c42\u5408\u5e76\u4ee5\u53ca\u54cd\u5e94\u5f0f\u6d41\u7684\u8f6c\u6362\u548c\u80cc\u538b\u63a7\u5236\u3002\u8fd9\u4e9b\u7279\u6027\u4e3a\u6784\u5efa\u9ad8\u6548\u3001\u5065\u58ee\u7684\u54cd\u5e94\u5f0f\u5e94\u7528\u63d0\u4f9b\u4e86\u66f4\u591a\u7684\u53ef\u80fd\u6027\u3002\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.talktop.cn\/?p=502\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.talktop.cn\/?p=502#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.talktop.cn\/?p=502\"},\"author\":{\"name\":\"AI\u98ce\u5411\u6807\",\"@id\":\"https:\/\/www.talktop.cn\/#\/schema\/person\/25908db5f654913a22bc38d48fad71ab\"},\"headline\":\"\u54cd\u5e94\u5f0f\u7f16\u7a0bSpring WebFlux \u8fdb\u9636\u7bc7\",\"datePublished\":\"2023-11-03T07:05:19+00:00\",\"dateModified\":\"2024-12-30T01:34:29+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.talktop.cn\/?p=502\"},\"wordCount\":21,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.talktop.cn\/#\/schema\/person\/25908db5f654913a22bc38d48fad71ab\"},\"image\":{\"@id\":\"https:\/\/www.talktop.cn\/?p=502#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.talktop.cn\/wp-content\/uploads\/2023\/11\/image-6.png\",\"keywords\":[\"WebFlux\"],\"articleSection\":[\"\u540e\u7aef\u5f00\u53d1\",\"\u7f16\u7a0b\u6280\u672f\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.talktop.cn\/?p=502#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.talktop.cn\/?p=502\",\"url\":\"https:\/\/www.talktop.cn\/?p=502\",\"name\":\"\u54cd\u5e94\u5f0f\u7f16\u7a0bSpring WebFlux \u8fdb\u9636\u7bc7\",\"isPartOf\":{\"@id\":\"https:\/\/www.talktop.cn\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.talktop.cn\/?p=502#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.talktop.cn\/?p=502#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.talktop.cn\/wp-content\/uploads\/2023\/11\/image-6.png\",\"datePublished\":\"2023-11-03T07:05:19+00:00\",\"dateModified\":\"2024-12-30T01:34:29+00:00\",\"description\":\"\u901a\u8fc7\u672c\u7bc7\u6587\u7ae0\uff0c\u6211\u4eec\u4e86\u89e3\u4e86Spring WebFlux\u7684\u4e00\u4e9b\u8fdb\u9636\u7279\u6027\uff0c\u5305\u62ec\u9519\u8bef\u5904\u7406\u3001\u7ebf\u7a0b\u6a21\u578b\u3001\u8bf7\u6c42\u5408\u5e76\u4ee5\u53ca\u54cd\u5e94\u5f0f\u6d41\u7684\u8f6c\u6362\u548c\u80cc\u538b\u63a7\u5236\u3002\u8fd9\u4e9b\u7279\u6027\u4e3a\u6784\u5efa\u9ad8\u6548\u3001\u5065\u58ee\u7684\u54cd\u5e94\u5f0f\u5e94\u7528\u63d0\u4f9b\u4e86\u66f4\u591a\u7684\u53ef\u80fd\u6027\u3002\",\"breadcrumb\":{\"@id\":\"https:\/\/www.talktop.cn\/?p=502#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.talktop.cn\/?p=502\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.talktop.cn\/?p=502#primaryimage\",\"url\":\"https:\/\/www.talktop.cn\/wp-content\/uploads\/2023\/11\/image-6.png\",\"contentUrl\":\"https:\/\/www.talktop.cn\/wp-content\/uploads\/2023\/11\/image-6.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.talktop.cn\/?p=502#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.talktop.cn\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u54cd\u5e94\u5f0f\u7f16\u7a0bSpring WebFlux \u8fdb\u9636\u7bc7\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.talktop.cn\/#website\",\"url\":\"https:\/\/www.talktop.cn\/\",\"name\":\"AI\u98ce\u5411\u6807\",\"description\":\"ChatGPT \u4eba\u5de5\u667a\u80fd \u7f16\u7a0b\u6280\u672f AIGC \u540e\u7aef\u6280\u672f \u524d\u7aef\u6280\u672f \u70ed\u95e8\u63d2\u4ef6 \u8fd0\u8425\u76f8\u5173 ChatGPT\u8ba2\u9605 Claude\u5145\u503c \u6d77\u5916\u5145\u503c \u8c37\u6b4c\u90ae\u7bb1\",\"publisher\":{\"@id\":\"https:\/\/www.talktop.cn\/#\/schema\/person\/25908db5f654913a22bc38d48fad71ab\"},\"alternateName\":\"AI\u98ce\u5411\u6807\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.talktop.cn\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/www.talktop.cn\/#\/schema\/person\/25908db5f654913a22bc38d48fad71ab\",\"name\":\"AI\u98ce\u5411\u6807\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.talktop.cn\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.talktop.cn\/wp-content\/uploads\/2023\/10\/cropped-f09060ba975518b80d3b0b63b47108a6.jpeg\",\"contentUrl\":\"https:\/\/www.talktop.cn\/wp-content\/uploads\/2023\/10\/cropped-f09060ba975518b80d3b0b63b47108a6.jpeg\",\"width\":512,\"height\":512,\"caption\":\"AI\u98ce\u5411\u6807\"},\"logo\":{\"@id\":\"https:\/\/www.talktop.cn\/#\/schema\/person\/image\/\"},\"sameAs\":[\"http:\/\/\/\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u54cd\u5e94\u5f0f\u7f16\u7a0bSpring WebFlux \u8fdb\u9636\u7bc7","description":"\u901a\u8fc7\u672c\u7bc7\u6587\u7ae0\uff0c\u6211\u4eec\u4e86\u89e3\u4e86Spring WebFlux\u7684\u4e00\u4e9b\u8fdb\u9636\u7279\u6027\uff0c\u5305\u62ec\u9519\u8bef\u5904\u7406\u3001\u7ebf\u7a0b\u6a21\u578b\u3001\u8bf7\u6c42\u5408\u5e76\u4ee5\u53ca\u54cd\u5e94\u5f0f\u6d41\u7684\u8f6c\u6362\u548c\u80cc\u538b\u63a7\u5236\u3002\u8fd9\u4e9b\u7279\u6027\u4e3a\u6784\u5efa\u9ad8\u6548\u3001\u5065\u58ee\u7684\u54cd\u5e94\u5f0f\u5e94\u7528\u63d0\u4f9b\u4e86\u66f4\u591a\u7684\u53ef\u80fd\u6027\u3002","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.talktop.cn\/?p=502","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.talktop.cn\/?p=502#article","isPartOf":{"@id":"https:\/\/www.talktop.cn\/?p=502"},"author":{"name":"AI\u98ce\u5411\u6807","@id":"https:\/\/www.talktop.cn\/#\/schema\/person\/25908db5f654913a22bc38d48fad71ab"},"headline":"\u54cd\u5e94\u5f0f\u7f16\u7a0bSpring WebFlux \u8fdb\u9636\u7bc7","datePublished":"2023-11-03T07:05:19+00:00","dateModified":"2024-12-30T01:34:29+00:00","mainEntityOfPage":{"@id":"https:\/\/www.talktop.cn\/?p=502"},"wordCount":21,"commentCount":0,"publisher":{"@id":"https:\/\/www.talktop.cn\/#\/schema\/person\/25908db5f654913a22bc38d48fad71ab"},"image":{"@id":"https:\/\/www.talktop.cn\/?p=502#primaryimage"},"thumbnailUrl":"https:\/\/www.talktop.cn\/wp-content\/uploads\/2023\/11\/image-6.png","keywords":["WebFlux"],"articleSection":["\u540e\u7aef\u5f00\u53d1","\u7f16\u7a0b\u6280\u672f"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.talktop.cn\/?p=502#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.talktop.cn\/?p=502","url":"https:\/\/www.talktop.cn\/?p=502","name":"\u54cd\u5e94\u5f0f\u7f16\u7a0bSpring WebFlux \u8fdb\u9636\u7bc7","isPartOf":{"@id":"https:\/\/www.talktop.cn\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.talktop.cn\/?p=502#primaryimage"},"image":{"@id":"https:\/\/www.talktop.cn\/?p=502#primaryimage"},"thumbnailUrl":"https:\/\/www.talktop.cn\/wp-content\/uploads\/2023\/11\/image-6.png","datePublished":"2023-11-03T07:05:19+00:00","dateModified":"2024-12-30T01:34:29+00:00","description":"\u901a\u8fc7\u672c\u7bc7\u6587\u7ae0\uff0c\u6211\u4eec\u4e86\u89e3\u4e86Spring WebFlux\u7684\u4e00\u4e9b\u8fdb\u9636\u7279\u6027\uff0c\u5305\u62ec\u9519\u8bef\u5904\u7406\u3001\u7ebf\u7a0b\u6a21\u578b\u3001\u8bf7\u6c42\u5408\u5e76\u4ee5\u53ca\u54cd\u5e94\u5f0f\u6d41\u7684\u8f6c\u6362\u548c\u80cc\u538b\u63a7\u5236\u3002\u8fd9\u4e9b\u7279\u6027\u4e3a\u6784\u5efa\u9ad8\u6548\u3001\u5065\u58ee\u7684\u54cd\u5e94\u5f0f\u5e94\u7528\u63d0\u4f9b\u4e86\u66f4\u591a\u7684\u53ef\u80fd\u6027\u3002","breadcrumb":{"@id":"https:\/\/www.talktop.cn\/?p=502#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.talktop.cn\/?p=502"]}]},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.talktop.cn\/?p=502#primaryimage","url":"https:\/\/www.talktop.cn\/wp-content\/uploads\/2023\/11\/image-6.png","contentUrl":"https:\/\/www.talktop.cn\/wp-content\/uploads\/2023\/11\/image-6.png"},{"@type":"BreadcrumbList","@id":"https:\/\/www.talktop.cn\/?p=502#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.talktop.cn\/"},{"@type":"ListItem","position":2,"name":"\u54cd\u5e94\u5f0f\u7f16\u7a0bSpring WebFlux \u8fdb\u9636\u7bc7"}]},{"@type":"WebSite","@id":"https:\/\/www.talktop.cn\/#website","url":"https:\/\/www.talktop.cn\/","name":"AI\u98ce\u5411\u6807","description":"ChatGPT \u4eba\u5de5\u667a\u80fd \u7f16\u7a0b\u6280\u672f AIGC \u540e\u7aef\u6280\u672f \u524d\u7aef\u6280\u672f \u70ed\u95e8\u63d2\u4ef6 \u8fd0\u8425\u76f8\u5173 ChatGPT\u8ba2\u9605 Claude\u5145\u503c \u6d77\u5916\u5145\u503c \u8c37\u6b4c\u90ae\u7bb1","publisher":{"@id":"https:\/\/www.talktop.cn\/#\/schema\/person\/25908db5f654913a22bc38d48fad71ab"},"alternateName":"AI\u98ce\u5411\u6807","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.talktop.cn\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":["Person","Organization"],"@id":"https:\/\/www.talktop.cn\/#\/schema\/person\/25908db5f654913a22bc38d48fad71ab","name":"AI\u98ce\u5411\u6807","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.talktop.cn\/#\/schema\/person\/image\/","url":"https:\/\/www.talktop.cn\/wp-content\/uploads\/2023\/10\/cropped-f09060ba975518b80d3b0b63b47108a6.jpeg","contentUrl":"https:\/\/www.talktop.cn\/wp-content\/uploads\/2023\/10\/cropped-f09060ba975518b80d3b0b63b47108a6.jpeg","width":512,"height":512,"caption":"AI\u98ce\u5411\u6807"},"logo":{"@id":"https:\/\/www.talktop.cn\/#\/schema\/person\/image\/"},"sameAs":["http:\/\/\/"]}]}},"_links":{"self":[{"href":"https:\/\/www.talktop.cn\/index.php?rest_route=\/wp\/v2\/posts\/502","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.talktop.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.talktop.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.talktop.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.talktop.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=502"}],"version-history":[{"count":0,"href":"https:\/\/www.talktop.cn\/index.php?rest_route=\/wp\/v2\/posts\/502\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.talktop.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=502"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.talktop.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=502"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.talktop.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=502"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}