{"id":340091,"date":"2022-10-22T03:00:17","date_gmt":"2022-10-22T03:00:17","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=340091"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=340091","title":{"rendered":"<span>\u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u043c\u0438\u0440: Project Reactor<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9fa\/da4\/0c6\/9fada40c66ed78138dafeb8d21226216.png\" width=\"881\" height=\"464\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9fa\/da4\/0c6\/9fada40c66ed78138dafeb8d21226216.png\"\/><figcaption><\/figcaption><\/figure>\n<p><strong>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/strong><\/p>\n<p>\u0423 \u043c\u043d\u043e\u0433\u0438\u0445 \u0438\u0437 \u043d\u0430\u0441, \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u0430\u043a\u043e\u0433\u043e-\u043b\u0438\u0431\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u043b \u0432\u043e\u043f\u0440\u043e\u0441: \u201c\u041a\u0430\u043a? \u041a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442?\u201d. \u0427\u0430\u0441\u0442\u043e \u043f\u0440\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0438 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u044f \u043e\u0431\u0440\u0430\u0449\u0430\u044e\u0441\u044c \u043a \u0433\u0443\u0433\u043b\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043e\u0431\u0449\u0438\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0442\u043e\u0433\u043e \u0438\u043b\u0438 \u0438\u043d\u043e\u0433\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430. \u041d\u043e \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0441\u0440\u0435\u0434\u0438 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u0439 \u0435\u0441\u0442\u044c \u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435, \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u0442\u0435\u0439, \u043f\u043e\u0434\u0443\u043c\u0430\u043b\u0438: &#171;\u0414\u0430, \u044d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0438, \u0432\u0440\u043e\u0434\u0435, \u043f\u043e\u043d\u044f\u0442\u043d\u043e. \u041d\u043e, \u0432\u0441\u0435-\u0442\u0430\u043a\u0438, \u043a\u0430\u043a \u043e\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442?&#187;.<\/p>\n<p>\u0422\u0430\u043a \u0432\u043e\u0442, \u044f \u0442\u043e\u0436\u0435 \u0432\u0445\u043e\u0436\u0443 \u0432 \u0447\u0438\u0441\u043b\u043e \u0442\u0430\u043a\u0438\u0445 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u0439. \u041f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0432 \u0441 \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u043c, \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0435\u043d \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u044b. \u041f\u043e\u043d\u044f\u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b, \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0441\u0430\u043c\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430. \u042f \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c Project Reactor \u0438\u0437\u043d\u0443\u0442\u0440\u0438 \u0438 \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u044e, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u043d\u0438\u044f. \u0415\u0441\u043b\u0438 \u043e\u043d\u0430 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439 \u0438 \u043d\u0430\u0439\u0434\u0435\u0442 \u0441\u0432\u043e\u044e \u0430\u0443\u0434\u0438\u0442\u043e\u0440\u0438\u044e, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u044f \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u044e \u0432\u044b\u0439\u0442\u0438 \u043d\u0430 \u0446\u0435\u043b\u044b\u0439 \u0446\u0438\u043a\u043b \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u043e\u0434 \u043a\u043e\u0434\u043e\u0432\u044b\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c &#171;\u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u043c\u0438\u0440&#187;.<\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0433\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0438\u0434\u0435\u0439 \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f &#8212; \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0441\u0442\u0430\u0442\u0435\u0439 \u0443\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0447\u0443\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0435, \u0447\u0435\u043c \u043c\u043d\u043e\u0433\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u044d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u044f \u043e\u0441\u0442\u0430\u0432\u043b\u044e \u0441\u0441\u044b\u043b\u043a\u0438 \u0432 \u043a\u043e\u043d\u0446\u0435 \u043d\u0430 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u043f\u043e \u0442\u0435\u043c\u0435. \u041e\u0434\u043d\u0430\u043a\u043e, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0441\u043d\u043e\u0432\u044b \u044f \u043d\u0430\u043f\u0438\u0448\u0443.<\/p>\n<h2>\u041e\u0431\u0449\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f<\/h2>\n<p>\u0420\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 &#8212; \u044d\u0442\u043e \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0421\u0430\u043c\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u043d\u0430 \u0448\u0438\u0440\u043e\u043a\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u043c \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0435 &#171;\u041d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u0435\u043b\u044c&#187; (\u0430 \u0442\u043e\u0447\u043d\u0435\u0435, \u0435\u0433\u043e \u0447\u0430\u0441\u0442\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 &#171;\u0418\u0437\u0434\u0430\u0442\u0435\u043b\u044c-\u041f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a&#187;): \u0435\u0441\u0442\u044c \u043f\u043e\u0442\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0440\u043e\u043b\u044c \u0438\u0437\u0434\u0430\u0442\u0435\u043b\u044f, \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u0432. \u0412 Java 9 \u0431\u044b\u043b \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442 \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0441\u0442\u0440\u0438\u043c\u043e\u0432 (\u043f\u0430\u043a\u0435\u0442 <code>org.reactivestreams<\/code>), \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0445 4 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430:<\/p>\n<ol>\n<li>\n<p><code>Publisher<\/code> &#8212; \u0438\u0437\u0434\u0430\u0442\u0435\u043b\u044c, \u0438\u043c\u0435\u044e\u0449\u0438\u0439 \u0442\u043e\u0447\u043a\u0443 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0438\u0437\u0434\u0430\u0442\u0435\u043b\u0435\u043c \u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u043c.<\/p>\n<details class=\"spoiler\">\n<summary>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 Publisher<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">public interface Publisher&lt;T> {     void subscribe(Subscriber&lt;? super T> var1); }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<\/li>\n<li>\n<p><code>Subscriber<\/code> &#8212; \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a, \u0438\u043c\u0435\u044e\u0449\u0438\u0439 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430:<\/p>\n<ul>\n<li>\n<p><code>onSubscribe()<\/code> \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0435;<\/p>\n<\/li>\n<li>\n<p><code>onNext()<\/code> \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043f\u043e\u0442\u043e\u043a\u0430;<\/p>\n<\/li>\n<li>\n<p><code>onError()<\/code> \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u043e\u0448\u0438\u0431\u043a\u0438;<\/p>\n<\/li>\n<li>\n<p><code>onComplete()<\/code> \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u043f\u043e\u0442\u043e\u043a\u0430.<\/p>\n<\/li>\n<\/ul>\n<details class=\"spoiler\">\n<summary>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 Subscriber<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">public interface Subscriber&lt;T> {     void onSubscribe(Subscription var1)     void onNext(T var1);     void onError(Throwable var1);     void onComplete(); }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<\/li>\n<li>\n<p><code>Subscription<\/code> &#8212; \u043e\u0431\u044a\u0435\u043a\u0442 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438. \u0421 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u0438\u043b\u0438 \u043e\u0442\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443.<\/p>\n<details class=\"spoiler\">\n<summary>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 Subscription<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">public interface Subscription {     void request(long var1);     void cancel(); }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<\/li>\n<li>\n<p><code>Processor<\/code> &#8212; \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0432 \u043f\u043e\u0442\u043e\u043a\u0435.<\/p>\n<details class=\"spoiler\">\n<summary>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 Processor<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">public interface Processor&lt;T, R> extends Subscriber&lt;T>, Publisher&lt;R> { }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<\/li>\n<\/ol>\n<p>\u0412 \u0446\u0435\u043b\u043e\u043c, \u0438\u0434\u0435\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430:\u00a0   <\/p>\n<ol>\n<li>\n<p><code>Subscriber<\/code> \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f <code>Publisher<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0412 \u043c\u0435\u0442\u043e\u0434\u0435 <code>Subscriber.onSubscribe()<\/code> \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c <code>Subscription.request()<\/code> \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0431\u044b\u0442\u0438\u044f \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0442 \u0447\u0435\u0440\u0435\u0437 \u0446\u0435\u043f\u043e\u0447\u043a\u0443 <code>Processor<\/code>&#8216;\u043e\u0432 \u0438 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u0432 \u043c\u0435\u0442\u043e\u0434 <code>Subscriber.onNext()<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044e \u043f\u043e\u0442\u043e\u043a\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>Subscriber.onComplete()<\/code>.<\/p>\n<\/li>\n<\/ol>\n<p>\u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u043e\u0434\u043d\u0443 \u0432\u0430\u0436\u043d\u0443\u044e \u0432\u0435\u0449\u044c, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u0443\u044e back-pressure (\u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0435 \u0434\u0430\u0432\u043b\u0435\u043d\u0438\u0435). \u041c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u043a\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e. \u042d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u0430\u043c\u043a\u0430\u043c\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438.\u00a0<\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c <code>Subscription.request()<\/code> \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>Subscriber.onSubscribe()<\/code>. \u0415\u0441\u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u043e\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c <code>Long.MAX_VALUE<\/code>. \u0415\u0441\u043b\u0438 \u0436\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c back-pressure, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c <code>Subscription.request()<\/code> \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>Subscriber.onNext()<\/code>, \u0447\u0442\u043e \u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u043c\u0435\u0440\u0435 \u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438.<\/p>\n<p>\u0412 \u0446\u0435\u043b\u043e\u043c, \u044d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u0432\u0441\u044f &#171;\u043e\u0431\u0449\u0430\u044f&#187; \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0441\u0442\u0440\u0438\u043c\u0430\u0445. \u0422\u0435\u043f\u0435\u0440\u044c \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0441\u0430\u043c\u043e\u043c\u0443 Project Reactor (\u0434\u0430\u043b\u0435\u0435 &#8212; \u0440\u0435\u0430\u043a\u0442\u043e\u0440).<\/p>\n<h2>\u041c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0441\u0442\u0440\u0438\u043c\u043e\u0432 \u0432 \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u0435<\/h2>\n<p>\u0412 \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u0435 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <code>Disposable<\/code>. \u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c \u0438 <code>Subscription<\/code> \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e <code>Subscription<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u043e\u0439 \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u0430, \u0430 <code>Disposable<\/code> &#8212; \u0438\u0437\u0432\u043d\u0435.<\/p>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u0430\u043c \u0441\u0442\u0440\u0438\u043c \u0432 \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u0435. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 <code>Flux<\/code>, \u043d\u043e \u0432\u0441\u0435, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u043d\u0438\u0436\u0435 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e \u0438 \u0434\u043b\u044f <code>Mono<\/code>.<\/p>\n<p>\u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0447\u0438\u0441\u043b\u0430 \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0443. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u043e, \u0447\u0442\u043e \u0431\u044b \u0437\u0430\u043d\u0438\u043c\u0430\u043b\u0430 \u0432\u0440\u0435\u043c\u044f.<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0435\u0434\u0438\u043a\u0430\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0443<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">private final Predicate&lt;Integer> checker = num -> {     for (int i = 2; i &lt; num; i++) {         if (num % i == 0) {             return false;         }     }     return true; };<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">private Integer[] generateIntArray(int size) {     Integer[] array = new Integer[size];     for (int i = 0; i &lt; size; i++) {         array[i] = ThreadLocalRandom.current().nextInt(90_000_000, 100_000_000);     }     return array; }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u0441\u0442\u0440\u0438\u043c\u0443:  <\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0435\u0440\u0432\u044b\u0439 \u0441\u0442\u0440\u0438\u043c<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">@Test public void reactorStream() {     Integer[] array = generateIntArray(100);      Flux.fromArray(array)             .filter(i -> i % 2 != 0)             .map(i -> \"Number \" + i + \" is prime: \" + checker.test(i))             .subscribe(System.out::println); }<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0432\u043e\u0434\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code>Number 94296669 is prime: false Number 94305859 is prime: false Number 92332843 is prime: true Number 90404043 is prime: false Number 99827085 is prime: false Number 90833557 is prime: false<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<\/div>\n<\/details>\n<p>\u041d\u0430 \u0442\u0430\u043a\u043e\u043c \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u043d\u0430\u0447\u043d\u0435\u043c \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u0430. \u0418\u0442\u0430\u043a, \u0447\u0442\u043e \u0442\u0443\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442? \u0423\u0441\u043b\u043e\u0432\u043d\u043e, \u0440\u0430\u0431\u043e\u0442\u0443 \u0441\u0442\u0440\u0438\u043c\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 3 \u0447\u0430\u0441\u0442\u0438: \u0441\u0431\u043e\u0440\u043a\u0430, \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0430 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435.<\/p>\n<p>\u041d\u0430\u0448 \u0441\u0442\u0440\u0438\u043c \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u0444\u0430\u0431\u0440\u0438\u0447\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 <code>Flux.fromArray()<\/code>. \u041f\u0440\u043e\u0432\u0430\u043b\u0438\u0432\u0448\u0438\u0441\u044c \u0432 \u043d\u0435\u0433\u043e \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043a\u043b\u0430\u0441\u0441 <code>Flux<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u043c, \u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u043c \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432 \u0432\u0438\u0434\u0435 <code>FluxArray<\/code>. \u0414\u043b\u044f \u0441\u0435\u0431\u044f \u044f \u043d\u0430\u0437\u0432\u0430\u043b \u0442\u0430\u043a\u043e\u0439 flux &#171;\u043f\u043e\u0440\u043e\u0436\u0434\u0430\u044e\u0449\u0438\u043c&#187;, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u0442\u043e\u0438\u0442 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u0438 \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u0443\u0435\u0442 \u0434\u0430\u043b\u044c\u0448\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0437 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0432 \u043d\u0435\u0433\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u0430. \u0422\u0430\u043a\u043e\u0439 &#171;\u043f\u043e\u0440\u043e\u0436\u0434\u0430\u044e\u0449\u0438\u0439&#187; flux \u043d\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439: \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>Flux.fromIterable()<\/code>, <code>Flux.fromStream()<\/code> \u0438 <code>Flux.range()<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 <code>FluxIterable<\/code>, <code>FluxStream<\/code> \u0438 <code>FluxRange<\/code> \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u041a\u0430\u0436\u0434\u044b\u0439 &#171;\u043f\u043e\u0440\u043e\u0436\u0434\u0430\u044e\u0449\u0438\u0439&#187; flux \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u0441\u0440\u0430\u0437\u0443 \u043e\u0442\u0441\u0435\u0438\u0432\u0430\u0435\u043c \u0447\u0435\u0442\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d\u0438 \u043d\u0430\u0441 \u043d\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442, \u0432\u044b\u0437\u0432\u0430\u0432 \u043c\u0435\u0442\u043e\u0434 <code>filter()<\/code>. \u041f\u0440\u043e\u0432\u0430\u043b\u0438\u0432\u0448\u0438\u0441\u044c \u0432 \u043d\u0435\u0433\u043e \u0432 \u043d\u0435\u0433\u043e, \u043c\u044b \u0443\u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u043e\u043d \u0442\u043e\u0436\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e flux &#8212; <code>FluxFilter<\/code>.<\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u043d\u043e\u0433\u043e &#171;\u043f\u043e\u0440\u043e\u0436\u0434\u0430\u044e\u0449\u0438\u0445&#187; \u0432\u0435\u0440\u0441\u0438\u0439 flux, \u043d\u043e \u0438 &#171;\u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u044e\u0449\u0438\u0445&#187;. \u0422\u0430\u043a, \u0432\u044b\u0437\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430\u043c\u0438 \u043c\u0435\u0442\u043e\u0434 <code>filter()<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0443\u0436\u0435 <code>FluxFilter<\/code>, \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u043c \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u044b\u0448\u0435\u0441\u0442\u043e\u044f\u0449\u0438\u0439 flux (\u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 &#8212; <code>FluxArray<\/code>). \u0412\u044b\u0437\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430\u043c\u0438 \u0434\u0430\u043b\u0435\u0435 map() \u0432 \u044d\u0442\u043e\u043c \u043f\u043b\u0430\u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a\u043e\u0435 \u0436\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435, \u043d\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0443\u0436\u0435 <code>FluxMap<\/code> (\u0430 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u043c \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>FluxFilter<\/code>).<\/p>\n<p>\u0414\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043c\u043e\u0433\u043b\u043e \u0431\u044b \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0432\u0441\u0435 \u0432\u044b\u0448\u0435\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u0431\u0435\u0437 \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u0430:<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0441\u0435\u0432\u0434\u043e\u043a\u043e\u0434: \u044d\u0442\u0430\u043f \u0441\u0431\u043e\u0440\u043a\u0438<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">Flux&lt;Integer> sourceFlux = Flux.fromArray(array); Flux&lt;Integer> filterFlux = new FluxFilter(sourceFlux, i -> i \/ 2 != 0); Flux&lt;Integer> mapFlux = new FluxMap(filterFlux, i -> \"Number \" + i + \" is prime: \" + checker.isPrimeNumber(i));<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0439 flux \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u043c \u043f\u0441\u0435\u0432\u0434\u043e\u043a\u043e\u0434\u043e\u043c:  <code>FluxMap(FluxFilter(FluxArray(source)))<\/code><\/p>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041d\u0430 \u0432\u044b\u0437\u043e\u0432\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 <code>subscribe()<\/code> \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u0430\u043f \u0441\u0431\u043e\u0440\u043a\u0438 \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u0430\u043f \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438. <\/p>\n<details class=\"spoiler\">\n<summary>\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0432 \u043e subscribe()<\/summary>\n<div class=\"spoiler__content\">\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043c\u044b \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u044d\u0442\u0430\u043f\u0443 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438, \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0432 \u043e \u0441\u0430\u043c\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435 <code>subscribe()<\/code>.<\/p>\n<p>\u0423\u0441\u043b\u043e\u0432\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 <code>subscribe()<\/code> \u0432 \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 2 \u0447\u0430\u0441\u0442\u0438: \u043c\u0435\u0442\u043e\u0434\u044b, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0438\u0445 \u043b\u044f\u043c\u0431\u0434\u044b \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u0438\u0433\u043d\u0430\u043b\u043e\u0432 \u0441\u0442\u0440\u0438\u043c\u0430, \u0438 \u043c\u0435\u0442\u043e\u0434, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0438\u0439 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e <code>CoreSubscriber<\/code>.\u00a0<\/p>\n<p>\u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0438\u0433\u043d\u0430\u043b\u043e\u0432 \u0441\u0442\u0440\u0438\u043c\u0430 \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u0446\u0438\u044f\u0445: \u043e\u0434\u043d\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e (\u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432), \u0434\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (\u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u043e\u0448\u0438\u0431\u043e\u043a), \u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (\u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u043e\u0448\u0438\u0431\u043e\u043a \u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043f\u0440\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u0441\u0442\u0440\u0438\u043c\u0430) \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u0412\u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u0438\u0437 \u043d\u0438\u0445 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f <code>LambdaSubscriber<\/code>.<\/p>\n<p>\u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u0432\u043e\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e <code>CoreSubscriber<\/code>. \u0414\u043b\u044f \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <code>BaseSubscriber<\/code>, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u043e\u043c.<\/p>\n<p>\u041e\u0442\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434 <code>subscribe()<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u0430\u043c \u043e\u0431\u044a\u0435\u043a\u0442 <code>Disposable<\/code>, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0442\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443 \u043d\u0430 \u0441\u0442\u0440\u0438\u043c &#171;\u0441\u043d\u0430\u0440\u0443\u0436\u0438&#187;.<\/p>\n<\/div>\n<\/details>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>subscribe()<\/code> \u0434\u043b\u044f &#171;\u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u044e\u0449\u0438\u0445&#187; flux \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0432 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 <code>InternalFluxOperator<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043d\u0438 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442. \u0412\u043d\u0443\u0442\u0440\u0438 \u043d\u0435\u0433\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u043e\u0432\u043e\u0435 &#171;\u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u0435&#187;, \u0443\u0436\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u0432: \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e &#171;\u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e&#187; flux \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u0432\u043e\u044f \u0432\u0435\u0440\u0441\u0438\u044f <code>CoreSubscriber<\/code> (\u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e <code>FilterSubscriber<\/code> \u0438 <code>MapSubscriber<\/code>). \u0423\u0441\u043b\u043e\u0432\u043d\u044b\u043c \u043f\u0441\u0435\u0432\u0434\u043e\u043a\u043e\u0434\u043e\u043c \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a:<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0441\u0435\u0432\u0434\u043e\u043a\u043e\u0434: \u044d\u0442\u0430\u043f \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">mapFlux.subscribe(Subscriber){ MapSubscriber mapSubscriber = new MapSubscriber(Subscriber); filterFlux.subscribe(mapSubscriber) { FilterSubscriber filterSubscriber = new FilterSubscriber(mapSubscriber); arrayFlux.subscribe(filterSubscriber) { \/\/ \u0420\u0435\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0430 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 } } } <\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e Subscriber \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u043c \u043f\u0441\u0435\u0432\u0434\u043e\u043a\u043e\u0434\u043e\u043c: <code>FilterSubscriber(MapSubscriber(Subscriber))<\/code><\/p>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u0430\u043f \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u0430\u043f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u0442\u043e\u043a\u0430.<\/p>\n<p>&#171;\u041f\u043e\u0440\u043e\u0436\u0434\u0430\u044e\u0449\u0438\u0435&#187; flux \u043d\u0435 \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u044e\u0442 <code>Subscriber<\/code> &#8212; \u043e\u043d\u0438 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442 \u0443 \u043d\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434 <code>onSibscribe()<\/code> \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442 \u0432 \u043d\u0435\u0433\u043e \u0441\u0432\u043e\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e <code>Subscription<\/code>. \u041a\u0430\u0436\u0434\u044b\u0439 &#171;\u043f\u043e\u0440\u043e\u0436\u0434\u0430\u044e\u0449\u0438\u0439&#187; flux \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u043e\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e <code>Subscription<\/code>: <code>ArraySubscription<\/code>, <code>IterableSubscription<\/code>, <code>StreamSubscription<\/code>, <code>RangeSubscription<\/code> \u0438 \u0442.\u0434. \u041a\u0430\u0436\u0434\u044b\u0439 <code>Subscriber<\/code> \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>onSibscribe()<\/code> \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0443 \u0441\u0435\u0431\u044f \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 <code>Subscription<\/code> \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0435\u0435 \u0432\u044b\u0448\u0435\u0441\u0442\u043e\u044f\u0449\u0435\u043c\u0443 \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u0443, \u0432\u043f\u043b\u043e\u0442\u044c \u0434\u043e \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 <code>onSubscribe()<\/code> \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0430 \u0438\u043c\u0435\u043d\u043d\u043e &#8212; \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 <code>Subscription.request()<\/code>) \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0442\u0440\u0438\u043c \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u0430\u043b.\u00a0<\/p>\n<details class=\"spoiler\">\n<summary>LambdaSubscriber \u043a\u0430\u043a \u043f\u0440\u0438\u043c\u0435\u0440<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>Consumer&lt;Subscription><\/code> \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u0441\u0442\u0440\u0438\u043c\u0430 &#8212; \u0432\u044b\u0437\u043e\u0432\u0435\u0442\u0441\u044f \u043e\u043d\u0430 (<code>subscriptionConsumer<\/code> \u0432 \u043a\u043e\u0434\u0435), \u0438\u043d\u0430\u0447\u0435 <code>LambdaSubscriber<\/code> \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u043c\u0435\u0440\u0435 \u0438\u0445 \u043f\u043e\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"java\">  public final void onSubscribe(Subscription s) {       if (Operators.validate(subscription, s)) {           this.subscription = s;           if (subscriptionConsumer != null) {               try {                   subscriptionConsumer.accept(s);               }               catch (Throwable t) {                   Exceptions.throwIfFatal(t);                   s.cancel();                   onError(t);               }           }           else {               s.request(Long.MAX_VALUE);           }       }   }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p><code>Subscription<\/code> \u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u043c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 &#8212; \u043e\u043d\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0440\u0435\u0441\u0443\u0440\u0441 (\u043c\u0430\u0441\u0441\u0438\u0432, \u0441\u0442\u0440\u0438\u043c \u0438 \u0442.\u0434.) \u0438 \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 <code>request()<\/code>\u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u043f\u043e\u0442\u043e\u043a\u0443. \u0422\u0430\u043a \u0436\u0435 <code>Subscription<\/code> \u0445\u0440\u0430\u043d\u0438\u0442 \u0438 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0433\u043e <code>Subscriber<\/code> (\u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 &#8212; <code>FilterSubscriber<\/code>), \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0432\u044b\u0437\u044b\u0432\u0430\u044f \u0443 \u043d\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434 <code>onNext()<\/code>. \u0418\u043c\u0435\u043d\u043d\u043e \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f\u0445 \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u0432 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432\u0441\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u043f\u043e\u0442\u043e\u043a\u0430. \u0414\u043b\u044f \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u043e\u043f\u0438\u0448\u0443 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u0442\u0440\u0438\u043c\u0430:<\/p>\n<ol>\n<li>\n<p><code>LambdaSubscriber<\/code> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <code>ArraySubscription.request(Long.MAX_VALUE)<\/code>.  <\/p>\n<\/li>\n<li>\n<p><code>ArraySubscription<\/code> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <code>FilterSubscriber.onNext()<\/code>. <\/p>\n<\/li>\n<li>\n<p><code>FilterSubscriber<\/code> \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043d\u0430\u043c\u0438 \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u0430, \u0438 \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <code>MapSubscriber.onNext()<\/code> \u0434\u043b\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u043f\u0440\u043e\u0448\u0435\u0434\u0448\u0438\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443.  <\/p>\n<\/li>\n<li>\n<p><code>MapSubscriber<\/code> \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0439 \u043d\u0430\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <code>LambdaSubscriber.onNext()<\/code>. <\/p>\n<\/li>\n<li>\n<p><code>LambdaSubscriber<\/code> \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u0443\u044e \u043d\u0430\u043c\u0438 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 subscribe() \u043b\u043e\u0433\u0438\u043a\u0443.  <\/p>\n<\/li>\n<li>\n<p>\u0412 \u043a\u043e\u043d\u0446\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 <code>ArraySubscription<\/code> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <code>FilterSubscriber.onComplete()<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u043e \u0442\u043e\u0439 \u0436\u0435 \u0446\u0435\u043f\u043e\u0447\u043a\u0435 \u0434\u043e <code>LambdaSubscriber<\/code> \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u0430\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u043b\u043e\u0433\u0438\u043a\u0430 (\u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043d\u0438\u043a\u0430\u043a\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u043b\u0438, \u043f\u043e\u0442\u043e\u043c\u0443 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442).  <\/p>\n<\/li>\n<\/ol>\n<p>\u042d\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0442\u0440\u0438\u043c\u0430. \u0412\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0440\u0435\u0437\u043e\u043d\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c: \u0430 \u0433\u0434\u0435 \u0436\u0435 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0441\u0442\u044c? \u0418 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0432 \u0432\u044b\u0448\u0435\u0441\u0442\u043e\u044f\u0449\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0441\u0442\u0438 \u043d\u0435\u0442, \u0432\u0441\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435. \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430\u0448 \u043a\u043e\u0434 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u0440\u044f\u0434 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0439.<\/p>\n<h2>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438<\/h2>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u043b\u043e\u0433\u0438\u043a\u0443 \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u0442\u0440\u0438\u043c\u0430. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>Flux.create()<\/code> \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0447\u0438\u0441\u0435\u043b. \u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u0444\u0438\u043b\u044c\u0442\u0440\u0443\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u043d\u0430 \u0447\u0435\u0442\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430, \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0443 \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0435 <code>flatMap()<\/code>. <code>FluxFlatMap<\/code> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0449\u0443\u044e \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 <code>Publisher<\/code> &#8212; \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u0440\u0438\u043c &#8212; \u0438 \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442 \u0435\u0433\u043e \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0439. \u0421\u0430\u043c \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a <code>FlatMapMain<\/code> \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 &#8212; \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0441\u043b\u043e\u0436\u043d\u0435\u0435.<\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0441\u0442\u0440\u0438\u043c \u0441\u0442\u0440\u0438\u043c<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">@Test public void syncStream() {     Flux.&lt;Integer>create(s -> {                 s.next(50);                 s.next(50);                 s.next(50);                 s.next(50);                 s.next(100);                 s.next(100);                 s.next(100);                 s.next(100);                 s.next(150);                 s.next(150);                 s.next(150);                 s.next(150);                 s.complete();             }).map(this::generateIntArray)             .map(array -> Arrays.stream(array)                     .filter(i -> (i % 2 != 0))                     .collect(Collectors.toList()))             .flatMap(list -> Flux.fromIterable(list)                     .map(i -> \"Number \" + i + \" is prime: \" + checker.test(i)))             .subscribe(result -> System.out.println(\"IN thread [\" + Thread.currentThread().getName() + \"] -> \" + result)); }<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u0427\u0430\u0441\u0442\u044c \u0432\u044b\u0432\u043e\u0434\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code>IN thread [main] -> Number 99126449 is prime: false IN thread [main] -> Number 99453773 is prime: true IN thread [main] -> Number 98450499 is prime: false IN thread [main] -> Number 90454073 is prime: false IN thread [main] -> Number 93393817 is prime: false<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<\/div>\n<\/details>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u0442\u043c\u0435\u0442\u0438\u043c, \u0447\u0442\u043e \u0432\u0441\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 main \u043f\u043e\u0442\u043e\u043a\u0435.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <code>subscribeOn()<\/code> \u0441 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c <code>Schedulers.boundedElastic()<\/code>. <code>Schedulers<\/code> &#8212; \u0430\u043d\u0430\u043b\u043e\u0433 <code>ExecutorService<\/code> \u0432 \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u0435, \u0430 \u0441\u0430\u043c <code>Schedulers.boundedElastic()<\/code> &#8212; \u0430\u043d\u0430\u043b\u043e\u0433 <code>Executors.newCachedThreadPool()<\/code>. \u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <code>subscribeOn()<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043f\u043e\u0442\u043e\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u0438\u043c\u0430, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438.\u00a0<\/p>\n<details class=\"spoiler\">\n<summary>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043e \u0448\u0435\u0434\u0443\u043b\u0435\u0440\u0430\u0445<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0412 \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b 3 \u0442\u0438\u043f\u0430 \u0448\u0435\u0434\u0443\u043b\u0435\u0440\u043e\u0432, \u043f\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0438 \u0441 <code>ExecutorService<\/code>:<\/p>\n<ul>\n<li>\n<p><code>Schedulers.boundedElastic()<\/code>: \u0430\u043d\u0430\u043b\u043e\u0433 <code>Executors.newCachedThreadPool()<\/code>. \u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0447\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 \u0438 \u043a\u044d\u0448\u0438\u0440\u0443\u0435\u0442 \u043f\u0443\u043b\u044b \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u041c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 \u043f\u0443\u043b\u043e\u0432 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044d\u0442\u043e\u0442 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u0432\u0432\u043e\u0434\u043e\u043c\/\u0432\u044b\u0432\u043e\u0434\u043e\u043c.<\/p>\n<\/li>\n<li>\n<p><code>Schedulers.parallel()<\/code>: \u0430\u043d\u0430\u043b\u043e\u0433 <code>Executors.newFixedThreadPool()<\/code>. \u0418\u043c\u0435\u0435\u0442 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u043f\u0443\u043b\u0430 \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0447\u0438\u0441\u043b\u043e\u043c \u044f\u0434\u0435\u0440 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430). \u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438.  <\/p>\n<\/li>\n<li>\n<p><code>Schedulers.single()<\/code>: \u0430\u043d\u0430\u043b\u043e\u0433 <code>Executors.newSingleThreadExecutor()<\/code>. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447 \u0432 \u043e\u0434\u043d\u043e\u043c \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435. \u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438.  <\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043d\u0438\u0445 \u0442\u0430\u043a\u0436\u0435 \u0438\u043c\u0435\u0435\u0442 \u043c\u0435\u0442\u043e\u0434\u044b \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0448\u0435\u0434\u0443\u043b\u0435\u0440 \u0438\u0437 <code>Executor<\/code> \u0438\u043b\u0438 <code>ExecutorService<\/code>.<\/p>\n<p>\u0411\u0443\u0434\u044c\u0442\u0435 \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u044b: \u043c\u0435\u0442\u043e\u0434\u044b <code>Schedulers.boundedElastic()<\/code>, <code>Schedulers.parallel()<\/code> \u0438 <code>Schedulers.single()<\/code> \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u0448\u0435\u0434\u0443\u043b\u0435\u0440 \u0435\u0434\u0438\u043d\u043e\u0436\u0434\u044b \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435 \u0438 \u043a\u044d\u0448\u0438\u0440\u0443\u044e\u0442 \u0435\u0433\u043e. \u0414\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u044d\u0442\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0432\u0435\u0440\u043d\u0443\u0442 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0448\u0435\u0434\u0443\u043b\u0435\u0440\u0430, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u043e \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 <code>Schedulers.parallel()<\/code> \u0438 <code>Schedulers.single()<\/code>.<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u0410\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0441\u0442\u0440\u0438\u043c<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">@Test public void asyncStream() {     Flux.&lt;Integer>create(s -> {                 s.next(50);                 s.next(50);                 s.next(50);                 s.next(50);                 s.next(100);                 s.next(100);                 s.next(100);                 s.next(100);                 s.next(150);                 s.next(150);                 s.next(150);                 s.next(150);                 s.complete();             }).map(this::generateIntArray)             .map(array -> Arrays.stream(array)                     .filter(i -> (i % 2 != 0))                     .collect(Collectors.toList()))             .flatMap(list -> Flux.fromIterable(list)                     .map(i -> \"Number \" + i + \" is prime: \" + checker.test(i)))             .subscribeOn(Schedulers.boundedElastic())             .subscribe(result -> System.out.println(\"IN thread [\" + Thread.currentThread().getName() + \"] -> \" + result)); }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043d\u0430\u0448 \u0441\u0442\u0440\u0438\u043c \u0438&#8230; \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u043e\u0441\u044c. \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043b\u0430\u0441\u044c. \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u0438\u043c\u0430 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u043b\u043e\u0441\u044c \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u0442\u043e\u043a, \u0430 \u043f\u043e\u0442\u043e\u043a main \u043f\u043e\u043f\u0440\u043e\u0441\u0442\u0443 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043b\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043e\u0439. \u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0442\u0430\u043a\u043e\u0435 \u0432\u0440\u044f\u0434 \u043b\u0438 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442, \u043d\u043e \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0442\u0435\u0441\u0442\u0430 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0437\u0430\u043c\u043e\u043a \u0434\u043b\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430.<\/p>\n<details class=\"spoiler\">\n<summary>\u0410\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0441\u0442\u0440\u0438\u043c 2<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">@Test public void asyncStream() throws InterruptedException {     var cdl = new CountDownLatch(1);      Flux.&lt;Integer>create(s -> {                 s.next(50);                 s.next(50);                 s.next(50);                 s.next(50);                 s.next(100);                 s.next(100);                 s.next(100);                 s.next(100);                 s.next(150);                 s.next(150);                 s.next(150);                 s.next(150);                 s.complete();             }).map(this::generateIntArray)             .map(array -> Arrays.stream(array)                     .filter(i -> (i % 2 != 0))                     .collect(Collectors.toList()))             .flatMap(list -> Flux.fromIterable(list)                     .map(i -> \"Number \" + i + \" is prime: \" + checker.test(i)))             .subscribeOn(Schedulers.boundedElastic())             .doFinally(ignore -> cdl.countDown())             .subscribe(result -> System.out.println(\"IN thread [\" + Thread.currentThread().getName() + \"] -> \" + result));      cdl.await(); }<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u0427\u0430\u0441\u0442\u044c \u0432\u044b\u0432\u043e\u0434\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code>IN thread [boundedElastic-1] -> Number 90553495 is prime: false IN thread [boundedElastic-1] -> Number 97965125 is prime: false IN thread [boundedElastic-1] -> Number 95508257 is prime: false IN thread [boundedElastic-1] -> Number 92073469 is prime: true IN thread [boundedElastic-1] -> Number 93561047 is prime: false IN thread [boundedElastic-1] -> Number 90207993 is prime: false IN thread [boundedElastic-1] -> Number 90418581 is prime: false<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<\/div>\n<\/details>\n<p>\u0412 \u043c\u0435\u0442\u043e\u0434\u0435 <code>doFinaly()<\/code> \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u0435 \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0437\u0430\u043c\u043a\u0430. \u041e\u0442\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c <code>s.complete()<\/code>, \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432\u044b\u0437\u0432\u0430\u043d \u043d\u0435 \u0431\u0443\u0434\u0435\u0442, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u043e\u0431 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043d\u0435 \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u0442.<\/p>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c, \u0438 \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0432\u0441\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0438\u0441\u044c \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435.<\/p>\n<p>\u0421\u043d\u043e\u0432\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u043d\u0430\u0448 \u0441\u0442\u0440\u0438\u043c, \u0437\u0430\u043c\u0435\u043d\u0438\u0432 <code>subscribeOn()<\/code> \u043d\u0430 <code>publishOn()<\/code>.\u00a0<\/p>\n<details class=\"spoiler\">\n<summary>\u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 publishOn()<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u044d\u0442\u0430\u043f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u0442\u043e\u043a.\u00a0 <code>publishOn()<\/code> \u0438\u043c\u0435\u0435\u0442 \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u0432\u0448\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043f\u043e\u0442\u043e\u043a. \u041a\u0430\u043a \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435, \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0434\u0432\u0430 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u044d\u0442\u0430\u043f\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/402\/0a5\/63e\/4020a563e4c4ddfce64a18f300b114b9.png\" width=\"510\" height=\"650\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/402\/0a5\/63e\/4020a563e4c4ddfce64a18f300b114b9.png\"\/><figcaption><\/figcaption><\/figure>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u0410\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0441\u0442\u0440\u0438\u043c 3<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">@Test public void asyncStream() throws InterruptedException {     var cdl = new CountDownLatch(1);      Flux.&lt;Integer>create(s -> {                 s.next(50);                 s.next(50);                 s.next(50);                 s.next(50);                 s.next(100);                 s.next(100);                 s.next(100);                 s.next(100);                 s.next(150);                 s.next(150);                 s.next(150);                 s.next(150);                 s.complete();             }).map(this::generateIntArray)             .map(array -> {                 System.out.println(\"IN thread [\" + Thread.currentThread().getName() + \"] -> filtering array with size: \" + array.length);                 return Arrays.stream(array)                         .filter(i -> (i % 2 != 0))                         .collect(Collectors.toList());             })             .publishOn(Schedulers.boundedElastic())             .flatMap(list -> Flux.fromIterable(list)                     .map(i -> \"Number \" + i + \" is prime: \" + checker.test(i)))             .doFinally(ignore -> cdl.countDown())             .subscribe(result -> System.out.println(\"IN thread [\" + Thread.currentThread().getName() + \"] -> \" + result));      cdl.await(); }<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u0427\u0430\u0441\u0442\u044c \u0432\u044b\u0432\u043e\u0434\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code>IN thread [main] -> filtering array with size: 150 IN thread [main] -> filtering array with size: 150 IN thread [main] -> filtering array with size: 150 IN thread [main] -> filtering array with size: 150 IN thread [boundedElastic-1] -> Number 97321949 is prime: false IN thread [boundedElastic-1] -> Number 92914819 is prime: false IN thread [boundedElastic-1] -> Number 94001827 is prime: false<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<\/div>\n<\/details>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c, \u0438 \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043f\u0435\u0440\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0440\u0438\u043c\u0430 \u043e\u0442\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0432 main \u043f\u043e\u0442\u043e\u043a\u0435, \u0430 \u043e\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0434\u0440\u0443\u0433\u043e\u043c. \u041c\u044b \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043b\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u0438\u043c\u0430 \u043d\u0430 2 \u0447\u0430\u0441\u0442\u0438 &#8212; \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u0447\u0442\u043e, \u0435\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0431\u043e\u043b\u044c\u0448\u0435? \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435?\u00a0<\/p>\n<details class=\"spoiler\">\n<summary>\u0410\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0441\u0442\u0440\u0438\u043c 4<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">@Test public void researchReactor_2_4() throws InterruptedException {     var cdl = new CountDownLatch(1);      Flux.&lt;Integer>create(s -> {                 s.next(50);                 s.next(50);                 s.next(50);                 s.next(50);                 s.next(100);                 s.next(100);                 s.next(100);                 s.next(100);                 s.next(150);                 s.next(150);                 s.next(150);                 s.next(150);                 s.complete();             }).map(this::generateIntArray)             .map(array -> {                 System.out.println(\"IN thread [\" + Thread.currentThread().getName() + \"] -> filtering array with size: \" + array.length);                 return Arrays.stream(array)                         .filter(i -> (i % 2 != 0))                         .collect(Collectors.toList());             })             .flatMap(list -> Flux.fromIterable(list)                     .publishOn(Schedulers.boundedElastic())                     .map(i -> \"Number \" + i + \" is prime: \" + checker.test(i)))             .doFinally(ignore -> cdl.countDown())             .subscribe(result -> System.out.println(\"IN thread [\" + Thread.currentThread().getName() + \"] -> \" + result));      cdl.await(); }<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u0427\u0430\u0441\u0442\u044c \u0432\u044b\u0432\u043e\u0434\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code>IN thread [main] -> filtering array with size: 150 IN thread [main] -> filtering array with size: 150 IN thread [boundedElastic-2] -> Number 98846721 is prime: false IN thread [boundedElastic-2] -> Number 92572645 is prime: false IN thread [boundedElastic-2] -> Number 98842737 is prime: false IN thread [boundedElastic-12] -> Number 95426589 is prime: false IN thread [boundedElastic-12] -> Number 91028725 is prime: false IN thread [boundedElastic-3] -> Number 91457669 is prime: true IN thread [boundedElastic-3] -> Number 95625013 is prime: false IN thread [boundedElastic-4] -> Number 91923637 is prime: false<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<\/div>\n<\/details>\n<p>\u041f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e, \u0442\u0435\u043f\u0435\u0440\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435. \u041d\u043e \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u043e\u0442\u043e\u043a \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438? \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u0435 \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f rest \u0432\u044b\u0437\u043e\u0432, \u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441?<\/p>\n<details class=\"spoiler\">\n<summary>\u0410\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0441\u0442\u0440\u0438\u043c 5<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">@Test public void researchReactor_2_5() throws InterruptedException {     var cdl = new CountDownLatch(1);      Flux.&lt;Integer>create(s -> {                 s.next(50);                 s.next(50);                 s.next(50);                 s.next(50);                 s.next(100);                 s.next(100);                 s.next(100);                 s.next(100);                 s.next(150);                 s.next(150);                 s.next(150);                 s.next(150);                 s.complete();             }).map(this::generateIntArray)             .map(array -> {                 System.out.println(\"IN thread [\" + Thread.currentThread().getName() + \"] -> filtering array with size: \" + array.length);                 return Arrays.stream(array)                         .filter(i -> (i % 2 != 0))                         .collect(Collectors.toList());             })             .flatMap(list -> Flux.fromIterable(list)                     .flatMap(i -> Mono.defer(() -> Mono.just(\"Number \" + i + \" is prime: \" + checker.test(i)))                             .subscribeOn(Schedulers.boundedElastic()))             )             .doFinally(ignore -> cdl.countDown())             .subscribe(result -> System.out.println(\"IN thread [\" + Thread.currentThread().getName() + \"] -> \" + result));      cdl.await(); }<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u0427\u0430\u0441\u0442\u044c \u0432\u044b\u0432\u043e\u0434\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code>IN thread [main] -> filtering array with size: 100 IN thread [boundedElastic-30] -> Number 92187347 is prime: false IN thread [boundedElastic-9] -> Number 96199459 is prime: false IN thread [boundedElastic-24] -> Number 96286047 is prime: false<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<\/div>\n<\/details>\n<p>\u0418 \u0432\u043e\u0442 \u043c\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043b\u0438 \u0446\u0435\u043b\u044b\u0445 5 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u0442\u043e\u043a\u0430: \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435, \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0432 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435, \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e \u0432 \u0434\u0432\u0443\u0445 \u043f\u043e\u0442\u043e\u043a\u0430\u0445 (\u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430, \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430), \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e \u043f\u043e \u043f\u043e\u0442\u043e\u043a\u0443 \u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432, \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e \u043f\u043e \u043f\u043e\u0442\u043e\u043a\u0443 \u043d\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u043c\u0435\u043d\u044f\u044f \u0441\u0430\u043c \u043a\u043e\u0434.<\/p>\n<details class=\"spoiler\">\n<summary>\u0425\u043e\u043b\u043e\u0434\u043d\u044b\u0435 \u0438 \u0433\u043e\u0440\u044f\u0447\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u0438<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0425\u043e\u043b\u043e\u0434\u043d\u044b\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0442 \u0432\u0441\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043d\u043e\u0432\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u0430. \u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0442\u0430\u043a\u0438\u0445 \u0441\u0442\u0440\u0438\u043c\u043e\u0432 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u0432\u044b\u0448\u0435.<\/p>\n<p>\u0413\u043e\u0440\u044f\u0447\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u0432. \u041f\u0440\u0438 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u0430 \u0442\u0430\u043a\u043e\u0439 \u0441\u0442\u0440\u0438\u043c \u043f\u043e\u0441\u044b\u043b\u0430\u0435\u0442 \u0435\u043c\u0443 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u043e\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0441\u043f\u0435\u043b \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434, \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a \u043d\u0430\u0447\u043d\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 3, \u0430 \u0432\u0442\u043e\u0440\u043e\u0439 &#8212; \u0441 7.<\/p>\n<pre><code class=\"java\">@Test public void hotStream() throws InterruptedException {     var cdl = new CountDownLatch(1);      Flux&lt;Integer> stream = Flux.range(0, 10)             .delayElements(Duration.ofMillis(500))             .doFinally(ignore -> cdl.countDown())             .subscribeOn(Schedulers.single())             .share();      stream.subscribe();      Thread.sleep(2000);      stream.subscribe(o -> System.out.println(\"[\" + Thread.currentThread().getName() + \"] Subscriber 1 -> \" + o));      Thread.sleep(2000);      stream.subscribe(o -> System.out.println(\"[\" + Thread.currentThread().getName() + \"] Subscriber 2 -> \" + o));      cdl.await(); }<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0433\u043e\u0440\u044f\u0447\u0435\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">@Test public void hotStream() throws InterruptedException {     var cdl = new CountDownLatch(1);      Flux&lt;Object> stream = Flux.create(fluxSink -> {                 while (true) {                     fluxSink.next(System.currentTimeMillis());                 }             })             .sample(Duration.ofMillis(500))             .doFinally(ignore -> cdl.countDown())             .subscribeOn(Schedulers.single())             .share();      stream.subscribe(o -> System.out.println(\"[\" + Thread.currentThread().getName() + \"] Subscriber 1 -> \" + o));      Thread.sleep(4000);      stream.subscribe(o -> System.out.println(\"[\" + Thread.currentThread().getName() + \"] Subscriber 2 -> \" + o));      cdl.await(); }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<\/div>\n<\/details>\n<h2>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043e\u043c<\/h2>\n<p>\u0415\u0449\u0435 \u043e\u0434\u043d\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0441\u0442\u0440\u0438\u043c\u0430. \u0412 \u201c\u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u201d \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 (\u201c\u043f\u043e\u0442\u043e\u043a \u043d\u0430 \u0437\u0430\u0434\u0430\u0447\u0443\u201d) \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0437\u0430\u0434\u0430\u0447\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0432 \u0435\u0433\u043e <code>ThreadLocal&lt;?><\/code> \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. \u0412 \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0441\u0442\u0440\u0438\u043c\u0430\u0445 \u0442\u0430\u043a\u043e\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043d\u0435\u0442, \u0442.\u043a. \u043e\u0434\u043d\u0443 \u0437\u0430\u0434\u0430\u0447\u0443 \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 \u0432 \u0440\u0430\u0437\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0435\u0441\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043a\u0430\u043a \u0442\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u0447\u0438, \u043d\u0435 \u043f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u044f\u0441\u044c \u043a \u043f\u043e\u0442\u043e\u043a\u0443-\u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044e. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 &#8212; \u043d\u0430\u0448 \u0441\u0442\u0440\u0438\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0447\u0438\u0441\u043b\u043e \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0435\u043c \u0447\u0438\u0441\u043b\u0430 \u0438\u0437 \u043f\u043e\u0442\u043e\u043a\u0430.<\/p>\n<p>\u0412 \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u0435 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043f\u043e\u0442\u043e\u043a\u0430:<\/p>\n<ul>\n<li>\n<p>\u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 1<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">@Test public void reactorContext_1() {     String ctxKey = \"key\";      Flux.fromArray(generateIntArray(10))             .flatMap(i -> Mono.deferContextual(ctx -> {                         int value = ctx.&lt;Integer>getOrEmpty(ctxKey).orElseThrow(() -> new IllegalArgumentException(\"Ctx key not found!\"));                         String result = i % value == 0                                 ? String.format(\"Thread [%s] -> %d divisor of the number %d\", Thread.currentThread().getName(), value, i)                                 : String.format(\"Thread [%s] -> %d NOT divisor of the number %d\", Thread.currentThread().getName(), value, i);                          return Mono.just(result);                     })             ).subscribe(System.out::println,                     null,                     null,                     Context.of(ctxKey, ThreadLocalRandom.current().nextInt(2, 10))); }<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0432\u043e\u0434\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code>Thread [main] -> 6 NOT divisor of the number 96484372 Thread [main] -> 6 NOT divisor of the number 99751334 Thread [main] -> 6 NOT divisor of the number 98114603 Thread [main] -> 6 NOT divisor of the number 94526528 Thread [main] -> 6 NOT divisor of the number 99601715 Thread [main] -> 6 NOT divisor of the number 94450652 Thread [main] -> 6 NOT divisor of the number 96186878 Thread [main] -> 6 divisor of the number 95334678 Thread [main] -> 6 NOT divisor of the number 91412254 Thread [main] -> 6 divisor of the number 97741992<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<\/div>\n<\/details>\n<\/li>\n<\/ul>\n<ul>\n<li>\n<p>\u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0435 <code>contextWrite()<\/code>  <\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 2<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">@Test public void reactorContext_2() {     String ctxKey = \"key\";      Flux.fromArray(generateIntArray(10))             .flatMap(i -> Mono.deferContextual(ctx -> {                         int value = ctx.&lt;Integer>getOrEmpty(ctxKey).orElseThrow(() -> new IllegalArgumentException(\"Ctx key not found!\"));                         String result = i % value == 0                                 ? String.format(\"Thread [%s] -> %d divisor of the number %d\", Thread.currentThread().getName(), value, i)                                 : String.format(\"Thread [%s] -> %d NOT divisor of the number %d\", Thread.currentThread().getName(), value, i);                          return Mono.just(result);                     })             ).contextWrite(ctx -> ctx.put(ctxKey, ThreadLocalRandom.current().nextInt(2, 10)))             .subscribe(System.out::println); }<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0432\u043e\u0434\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code>Thread [main] -> 3 divisor of the number 94070187 Thread [main] -> 3 NOT divisor of the number 96881164 Thread [main] -> 3 NOT divisor of the number 93117008 Thread [main] -> 3 NOT divisor of the number 99847222 Thread [main] -> 3 NOT divisor of the number 99232121 Thread [main] -> 3 divisor of the number 90207831 Thread [main] -> 3 divisor of the number 98137233 Thread [main] -> 3 divisor of the number 93991545 Thread [main] -> 3 divisor of the number 99188091 Thread [main] -> 3 divisor of the number 99287157<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 3<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">@Test public void reactorContext_2_1() {     String ctxKey = \"key\";      Flux.fromArray(generateIntArray(10))             .flatMap(i -> Mono.deferContextual(ctx -> {                         int value = ctx.&lt;Integer>getOrEmpty(ctxKey).orElseThrow(() -> new IllegalArgumentException(\"Ctx key not found!\"));                         String result = i % value == 0                                 ? String.format(\"Thread [%s] -> %d divisor of the number %d\", Thread.currentThread().getName(), value, i)                                 : String.format(\"Thread [%s] -> %d NOT divisor of the number %d\", Thread.currentThread().getName(), value, i);                          return Mono.just(result);                     })             ).contextWrite(Context.of(ctxKey, ThreadLocalRandom.current().nextInt(2, 10)))             .subscribe(System.out::println); }<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0432\u043e\u0434\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code>Thread [main] -> 4 divisor of the number 94968444 Thread [main] -> 4 divisor of the number 98424152 Thread [main] -> 4 NOT divisor of the number 99689442 Thread [main] -> 4 divisor of the number 97327236 Thread [main] -> 4 NOT divisor of the number 94170947 Thread [main] -> 4 divisor of the number 96579680 Thread [main] -> 4 NOT divisor of the number 91238971 Thread [main] -> 4 NOT divisor of the number 90252134 Thread [main] -> 4 divisor of the number 95264784 Thread [main] -> 4 NOT divisor of the number 99502289<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<\/div>\n<\/details>\n<\/li>\n<\/ul>\n<p>\u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0431\u0443\u0434\u0435\u0442 \u0432\u0438\u0434\u0435\u043d \u0432\u043e \u0432\u0441\u0435\u0445 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430\u0445, \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0432\u044b\u0448\u0435 \u043f\u043e \u0446\u0435\u043f\u043e\u0447\u043a\u0435. \u0415\u0441\u043b\u0438 \u043c\u044b \u043e\u0431\u044a\u044f\u0432\u0438\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u0442\u0440\u0438\u043c\u0430, \u0442\u043e \u0443\u0432\u0438\u0434\u0438\u043c \u043e\u0448\u0438\u0431\u043a\u0443<\/p>\n<details class=\"spoiler\">\n<summary>\u041e\u0448\u0438\u0431\u043e\u0447\u043d\u043e\u0435 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0443 1<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">@Test public void reactorContext_3() {     String ctxKey = \"key\";      Flux.fromArray(generateIntArray(10))             .contextWrite(ctx -> ctx.put(ctxKey, 4))             .flatMap(i -> Mono.deferContextual(ctx -> {                         int value = ctx.&lt;Integer>getOrEmpty(ctxKey).orElseThrow(() -> new IllegalArgumentException(\"Ctx key not found!\"));                         String result = i % value == 0                                 ? String.format(\"Thread [%s] -> %d divisor of the number %d\", Thread.currentThread().getName(), value, i)                                 : String.format(\"Thread [%s] -> %d NOT divisor of the number %d\", Thread.currentThread().getName(), value, i);                          return Mono.just(result);                     })             ).subscribe(System.out::println); }<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0432\u043e\u0434\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code>[ERROR] (main) Operator called default onErrorDropped - reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.IllegalArgumentException: Ctx key not found! reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.IllegalArgumentException: Ctx key not found! Caused by: java.lang.IllegalArgumentException: Ctx key not found! at ru.brutforcer.reactor.aricle.ReactorTests.lambda$reactorContext_3$62(ReactorTests.java:340) at java.base\/java.util.Optional.orElseThrow(Optional.java:403)<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<\/div>\n<\/details>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0434\u043b\u044f \u201c\u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0439\u201d \u0446\u0435\u043f\u043e\u0447\u043a\u0438. \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e  \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e \u0440\u0430\u043d\u0434\u043e\u043c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e: \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u0432\u044b\u0448\u0435 \u043e\u043d\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0435\u0434\u0438\u043d\u043e\u0436\u0434\u044b \u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0435\u0434\u0438\u043d\u044b\u043c \u0434\u043b\u044f \u0432\u0441\u0435\u0433\u043e \u0441\u0442\u0440\u0438\u043c\u0430. \u0412 \u043d\u043e\u0432\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u0432\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438.<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 4<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">@Test public void reactorContext_4() {     String ctxKey = \"key\";      Flux.fromArray(generateIntArray(10))             .flatMap(i -> Mono.deferContextual(ctx -> {                     int value = ctx.&lt;Integer>getOrEmpty(ctxKey).orElseThrow(() -> new IllegalArgumentException(\"Ctx key not found!\"));                     String result = i % value == 0                             ? String.format(\"Thread [%s] -> %d divisor of the number %d\", Thread.currentThread().getName(), value, i)                             : String.format(\"Thread [%s] -> %d NOT divisor of the number %d\", Thread.currentThread().getName(), value, i);                      return Mono.just(result);                 }).contextWrite(ctx -> ctx.put(ctxKey, ThreadLocalRandom.current().nextInt(2, 10)))             ).subscribe(System.out::println); }<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0432\u043e\u0434\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code>Thread [main] -> 4 NOT divisor of the number 91486019 Thread [main] -> 2 NOT divisor of the number 95953267 Thread [main] -> 5 NOT divisor of the number 95931323 Thread [main] -> 4 NOT divisor of the number 99936074 Thread [main] -> 4 divisor of the number 99891164 Thread [main] -> 3 divisor of the number 96090381 Thread [main] -> 9 NOT divisor of the number 97190858 Thread [main] -> 9 NOT divisor of the number 97639514 Thread [main] -> 4 divisor of the number 90896348 Thread [main] -> 4 NOT divisor of the number 98617771<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<\/div>\n<\/details>\n<p>\u0418 \u0432\u0430\u0436\u043d\u0430\u044f \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c: \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442, \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0432\u043e \u201c\u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0439\u201d \u0446\u0435\u043f\u043e\u0447\u043a\u0435, \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u0438\u0434\u0435\u043d \u0432\u043e \u201c\u0432\u043d\u0435\u0448\u043d\u0435\u0439\u201d. \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0438\u0436\u0435 \u0432\u044b\u0439\u0434\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430.<\/p>\n<details class=\"spoiler\">\n<summary>\u041e\u0448\u0438\u0431\u043e\u0447\u043d\u043e\u0435 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0443 2<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">@Test public void reactorContext_5() {     String ctxKey = \"key\";      Flux.fromArray(generateIntArray(10))             .flatMap(i -> Mono.&lt;Integer>deferContextual(ctx -> {                 int v = ctx.&lt;Integer>getOrEmpty(ctxKey).orElseThrow(() -> new IllegalArgumentException(\"Ctx key not found!\"));                 return Mono.just(i);             }))             .flatMap(i -> Mono.deferContextual(ctx -> Mono.just(i))                     .contextWrite(ctx -> ctx.put(ctxKey, ThreadLocalRandom.current().nextInt(2, 10))))             .subscribe(System.out::println); }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h2>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438<\/h2>\n<ul>\n<li>\n<p><strong><em>\u041e\u043b\u0435\u0433 \u0414\u043e\u043a\u0443\u043a\u0430, \u0418\u0433\u043e\u0440\u044c \u041b\u043e\u0437\u0438\u043d\u0441\u043a\u0438\u0439 \u201c\u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0430 \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432 Spring 5\u201d<\/em><\/strong> &#8212; \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u0430\u044f \u043a\u043d\u0438\u0433\u0430 \u0434\u043b\u044f \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u0438 \u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0432 \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u0440\u0430\u0434\u0438\u0433\u043c\u0435. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043c\u0438\u043d\u0443\u0441 &#8212; \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u043e \u0440\u0435\u0430\u043a\u0442\u043e\u0440 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0430 \u0434\u043b\u044f 2 \u0432\u0435\u0440\u0441\u0438\u0438 \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u0430: \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043a\u043d\u0438\u0433\u0438 \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u0435\u0441\u0442\u0430\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f deprecated \u043c\u0435\u0442\u043e\u0434\u044b, \u0430 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0442\u043e\u0447\u043d\u044b\u043c \u0434\u043b\u044f \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.reactive-streams.org\/\" rel=\"noopener noreferrer nofollow\">\u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0441\u0442\u0440\u0438\u043c\u043e\u0432  <\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.reactivemanifesto.org\/\" rel=\"noopener noreferrer nofollow\">\u0420\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442  <\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/565004\/\" rel=\"noopener noreferrer nofollow\">\u0420\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043e Spring, \u0447\u0430\u0441\u0442\u044c 1 \u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435  <\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/565050\/\" rel=\"noopener noreferrer nofollow\">\u0420\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043e Spring, \u0447\u0430\u0441\u0442\u044c 2 Project Reactor  <\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/company\/oleg-bunin\/blog\/545702\/\" rel=\"noopener noreferrer nofollow\">\u0420\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 Java: \u043a\u0430\u043a, \u0437\u0430\u0447\u0435\u043c \u0438 \u0441\u0442\u043e\u0438\u0442 \u043b\u0438?  <\/a><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/694850\/\"> https:\/\/habr.com\/ru\/post\/694850\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p><strong>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/strong><\/p>\n<p>\u0423 \u043c\u043d\u043e\u0433\u0438\u0445 \u0438\u0437 \u043d\u0430\u0441, \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u0430\u043a\u043e\u0433\u043e-\u043b\u0438\u0431\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u043b \u0432\u043e\u043f\u0440\u043e\u0441: \u201c\u041a\u0430\u043a? \u041a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442?\u201d. \u0427\u0430\u0441\u0442\u043e \u043f\u0440\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0438 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u044f \u043e\u0431\u0440\u0430\u0449\u0430\u044e\u0441\u044c \u043a \u0433\u0443\u0433\u043b\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043e\u0431\u0449\u0438\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0442\u043e\u0433\u043e \u0438\u043b\u0438 \u0438\u043d\u043e\u0433\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430. \u041d\u043e \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0441\u0440\u0435\u0434\u0438 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u0439 \u0435\u0441\u0442\u044c \u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435, \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u0442\u0435\u0439, \u043f\u043e\u0434\u0443\u043c\u0430\u043b\u0438: &#171;\u0414\u0430, \u044d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0438, \u0432\u0440\u043e\u0434\u0435, \u043f\u043e\u043d\u044f\u0442\u043d\u043e. \u041d\u043e, \u0432\u0441\u0435-\u0442\u0430\u043a\u0438, \u043a\u0430\u043a \u043e\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442?&#187;.<\/p>\n<p>\u0422\u0430\u043a \u0432\u043e\u0442, \u044f \u0442\u043e\u0436\u0435 \u0432\u0445\u043e\u0436\u0443 \u0432 \u0447\u0438\u0441\u043b\u043e \u0442\u0430\u043a\u0438\u0445 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u0439. \u041f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0432 \u0441 \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u043c, \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0435\u043d \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u044b. \u041f\u043e\u043d\u044f\u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b, \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0441\u0430\u043c\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430. \u042f \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c Project Reactor \u0438\u0437\u043d\u0443\u0442\u0440\u0438 \u0438 \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u044e, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u043d\u0438\u044f. \u0415\u0441\u043b\u0438 \u043e\u043d\u0430 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439 \u0438 \u043d\u0430\u0439\u0434\u0435\u0442 \u0441\u0432\u043e\u044e \u0430\u0443\u0434\u0438\u0442\u043e\u0440\u0438\u044e, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u044f \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u044e \u0432\u044b\u0439\u0442\u0438 \u043d\u0430 \u0446\u0435\u043b\u044b\u0439 \u0446\u0438\u043a\u043b \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u043e\u0434 \u043a\u043e\u0434\u043e\u0432\u044b\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c &#171;\u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u043c\u0438\u0440&#187;.<\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0433\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0438\u0434\u0435\u0439 \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f &#8212; \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0441\u0442\u0430\u0442\u0435\u0439 \u0443\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0447\u0443\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0435, \u0447\u0435\u043c \u043c\u043d\u043e\u0433\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u044d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u044f \u043e\u0441\u0442\u0430\u0432\u043b\u044e \u0441\u0441\u044b\u043b\u043a\u0438 \u0432 \u043a\u043e\u043d\u0446\u0435 \u043d\u0430 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u043f\u043e \u0442\u0435\u043c\u0435. \u041e\u0434\u043d\u0430\u043a\u043e, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0441\u043d\u043e\u0432\u044b \u044f \u043d\u0430\u043f\u0438\u0448\u0443.<\/p>\n<h2>\u041e\u0431\u0449\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f<\/h2>\n<p>\u0420\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 &#8212; \u044d\u0442\u043e \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0421\u0430\u043c\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u043d\u0430 \u0448\u0438\u0440\u043e\u043a\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u043c \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0435 &#171;\u041d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u0435\u043b\u044c&#187; (\u0430 \u0442\u043e\u0447\u043d\u0435\u0435, \u0435\u0433\u043e \u0447\u0430\u0441\u0442\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 &#171;\u0418\u0437\u0434\u0430\u0442\u0435\u043b\u044c-\u041f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a&#187;): \u0435\u0441\u0442\u044c \u043f\u043e\u0442\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0440\u043e\u043b\u044c \u0438\u0437\u0434\u0430\u0442\u0435\u043b\u044f, \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u0432. \u0412 Java 9 \u0431\u044b\u043b \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442 \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0441\u0442\u0440\u0438\u043c\u043e\u0432 (\u043f\u0430\u043a\u0435\u0442 <code>org.reactivestreams<\/code>), \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0445 4 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430:<\/p>\n<ol>\n<li>\n<p><code>Publisher<\/code> &#8212; \u0438\u0437\u0434\u0430\u0442\u0435\u043b\u044c, \u0438\u043c\u0435\u044e\u0449\u0438\u0439 \u0442\u043e\u0447\u043a\u0443 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0438\u0437\u0434\u0430\u0442\u0435\u043b\u0435\u043c \u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u043c.<\/p>\n<details class=\"spoiler\">\n<summary>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 Publisher<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">public interface Publisher&lt;T> {     void subscribe(Subscriber&lt;? super T> var1); }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<\/li>\n<li>\n<p><code>Subscriber<\/code> &#8212; \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a, \u0438\u043c\u0435\u044e\u0449\u0438\u0439 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430:<\/p>\n<ul>\n<li>\n<p><code>onSubscribe()<\/code> \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0435;<\/p>\n<\/li>\n<li>\n<p><code>onNext()<\/code> \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043f\u043e\u0442\u043e\u043a\u0430;<\/p>\n<\/li>\n<li>\n<p><code>onError()<\/code> \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u043e\u0448\u0438\u0431\u043a\u0438;<\/p>\n<\/li>\n<li>\n<p><code>onComplete()<\/code> \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u043f\u043e\u0442\u043e\u043a\u0430.<\/p>\n<\/li>\n<\/ul>\n<details class=\"spoiler\">\n<summary>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 Subscriber<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">public interface Subscriber&lt;T> {     void onSubscribe(Subscription var1)     void onNext(T var1);     void onError(Throwable var1);     void onComplete(); }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<\/li>\n<li>\n<p><code>Subscription<\/code> &#8212; \u043e\u0431\u044a\u0435\u043a\u0442 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438. \u0421 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u0438\u043b\u0438 \u043e\u0442\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443.<\/p>\n<details class=\"spoiler\">\n<summary>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 Subscription<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">public interface Subscription {     void request(long var1);     void cancel(); }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<\/li>\n<li>\n<p><code>Processor<\/code> &#8212; \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0432 \u043f\u043e\u0442\u043e\u043a\u0435.<\/p>\n<details class=\"spoiler\">\n<summary>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 Processor<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">public interface Processor&lt;T, R> extends Subscriber&lt;T>, Publisher&lt;R> { }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<\/li>\n<\/ol>\n<p>\u0412 \u0446\u0435\u043b\u043e\u043c, \u0438\u0434\u0435\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430:\u00a0   <\/p>\n<ol>\n<li>\n<p><code>Subscriber<\/code> \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f <code>Publisher<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0412 \u043c\u0435\u0442\u043e\u0434\u0435 <code>Subscriber.onSubscribe()<\/code> \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c <code>Subscription.request()<\/code> \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0431\u044b\u0442\u0438\u044f \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0442 \u0447\u0435\u0440\u0435\u0437 \u0446\u0435\u043f\u043e\u0447\u043a\u0443 <code>Processor<\/code>&#8216;\u043e\u0432 \u0438 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u0432 \u043c\u0435\u0442\u043e\u0434 <code>Subscriber.onNext()<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044e \u043f\u043e\u0442\u043e\u043a\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>Subscriber.onComplete()<\/code>.<\/p>\n<\/li>\n<\/ol>\n<p>\u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u043e\u0434\u043d\u0443 \u0432\u0430\u0436\u043d\u0443\u044e \u0432\u0435\u0449\u044c, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u0443\u044e back-pressure (\u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0435 \u0434\u0430\u0432\u043b\u0435\u043d\u0438\u0435). \u041c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u043a\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e. \u042d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u0430\u043c\u043a\u0430\u043c\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438.\u00a0<\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c <code>Subscription.request()<\/code> \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>Subscriber.onSubscribe()<\/code>. \u0415\u0441\u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u043e\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c <code>Long.MAX_VALUE<\/code>. \u0415\u0441\u043b\u0438 \u0436\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c back-pressure, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c <code>Subscription.request()<\/code> \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>Subscriber.onNext()<\/code>, \u0447\u0442\u043e \u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u043c\u0435\u0440\u0435 \u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438.<\/p>\n<p>\u0412 \u0446\u0435\u043b\u043e\u043c, \u044d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u0432\u0441\u044f &#171;\u043e\u0431\u0449\u0430\u044f&#187; \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0441\u0442\u0440\u0438\u043c\u0430\u0445. \u0422\u0435\u043f\u0435\u0440\u044c \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0441\u0430\u043c\u043e\u043c\u0443 Project Reactor (\u0434\u0430\u043b\u0435\u0435 &#8212; \u0440\u0435\u0430\u043a\u0442\u043e\u0440).<\/p>\n<h2>\u041c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0441\u0442\u0440\u0438\u043c\u043e\u0432 \u0432 \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u0435<\/h2>\n<p>\u0412 \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u0435 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <code>Disposable<\/code>. \u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c \u0438 <code>Subscription<\/code> \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e <code>Subscription<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u043e\u0439 \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u0430, \u0430 <code>Disposable<\/code> &#8212; \u0438\u0437\u0432\u043d\u0435.<\/p>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u0430\u043c \u0441\u0442\u0440\u0438\u043c \u0432 \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u0435. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 <code>Flux<\/code>, \u043d\u043e \u0432\u0441\u0435, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u043d\u0438\u0436\u0435 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e \u0438 \u0434\u043b\u044f <code>Mono<\/code>.<\/p>\n<p>\u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0447\u0438\u0441\u043b\u0430 \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0443. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u043e, \u0447\u0442\u043e \u0431\u044b \u0437\u0430\u043d\u0438\u043c\u0430\u043b\u0430 \u0432\u0440\u0435\u043c\u044f.<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0435\u0434\u0438\u043a\u0430\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0443<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">private final Predicate&lt;Integer> checker = num -> {     for (int i = 2; i &lt; num; i++) {         if (num % i == 0) {             return false;         }     }     return true; };<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">private Integer[] generateIntArray(int size) {     Integer[] array = new Integer[size];     for (int i = 0; i &lt; size; i++) {         array[i] = ThreadLocalRandom.current().nextInt(90_000_000, 100_000_000);     }     return array; }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u0441\u0442\u0440\u0438\u043c\u0443:  <\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0435\u0440\u0432\u044b\u0439 \u0441\u0442\u0440\u0438\u043c<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">@Test public void reactorStream() {     Integer[] array = generateIntArray(100);      Flux.fromArray(array)             .filter(i -> i % 2 != 0)             .map(i -> \"Number \" + i + \" is prime: \" + checker.test(i))             .subscribe(System.out::println); }<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0432\u043e\u0434\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code>Number 94296669 is prime: false Number 94305859 is prime: false Number 92332843 is prime: true Number 90404043 is prime: false Number 99827085 is prime: false Number 90833557 is prime: false<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<\/div>\n<\/details>\n<p>\u041d\u0430 \u0442\u0430\u043a\u043e\u043c \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u043d\u0430\u0447\u043d\u0435\u043c \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u0430. \u0418\u0442\u0430\u043a, \u0447\u0442\u043e \u0442\u0443\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442? \u0423\u0441\u043b\u043e\u0432\u043d\u043e, \u0440\u0430\u0431\u043e\u0442\u0443 \u0441\u0442\u0440\u0438\u043c\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 3 \u0447\u0430\u0441\u0442\u0438: \u0441\u0431\u043e\u0440\u043a\u0430, \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0430 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435.<\/p>\n<p>\u041d\u0430\u0448 \u0441\u0442\u0440\u0438\u043c \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u0444\u0430\u0431\u0440\u0438\u0447\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 <code>Flux.fromArray()<\/code>. \u041f\u0440\u043e\u0432\u0430\u043b\u0438\u0432\u0448\u0438\u0441\u044c \u0432 \u043d\u0435\u0433\u043e \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043a\u043b\u0430\u0441\u0441 <code>Flux<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u043c, \u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u043c \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432 \u0432\u0438\u0434\u0435 <code>FluxArray<\/code>. \u0414\u043b\u044f \u0441\u0435\u0431\u044f \u044f \u043d\u0430\u0437\u0432\u0430\u043b \u0442\u0430\u043a\u043e\u0439 flux &#171;\u043f\u043e\u0440\u043e\u0436\u0434\u0430\u044e\u0449\u0438\u043c&#187;, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u0442\u043e\u0438\u0442 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u0438 \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u0443\u0435\u0442 \u0434\u0430\u043b\u044c\u0448\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0437 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0432 \u043d\u0435\u0433\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u0430. \u0422\u0430\u043a\u043e\u0439 &#171;\u043f\u043e\u0440\u043e\u0436\u0434\u0430\u044e\u0449\u0438\u0439&#187; flux \u043d\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439: \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>Flux.fromIterable()<\/code>, <code>Flux.fromStream()<\/code> \u0438 <code>Flux.range()<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 <code>FluxIterable<\/code>, <code>FluxStream<\/code> \u0438 <code>FluxRange<\/code> \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u041a\u0430\u0436\u0434\u044b\u0439 &#171;\u043f\u043e\u0440\u043e\u0436\u0434\u0430\u044e\u0449\u0438\u0439&#187; flux \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u0441\u0440\u0430\u0437\u0443 \u043e\u0442\u0441\u0435\u0438\u0432\u0430\u0435\u043c \u0447\u0435\u0442\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d\u0438 \u043d\u0430\u0441 \u043d\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442, \u0432\u044b\u0437\u0432\u0430\u0432 \u043c\u0435\u0442\u043e\u0434 <code>filter()<\/code>. \u041f\u0440\u043e\u0432\u0430\u043b\u0438\u0432\u0448\u0438\u0441\u044c \u0432 \u043d\u0435\u0433\u043e \u0432 \u043d\u0435\u0433\u043e, \u043c\u044b \u0443\u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u043e\u043d \u0442\u043e\u0436\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e flux &#8212; <code>FluxFilter<\/code>.<\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u043d\u043e\u0433\u043e &#171;\u043f\u043e\u0440\u043e\u0436\u0434\u0430\u044e\u0449\u0438\u0445&#187; \u0432\u0435\u0440\u0441\u0438\u0439 flux, \u043d\u043e \u0438 &#171;\u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u044e\u0449\u0438\u0445&#187;. \u0422\u0430\u043a, \u0432\u044b\u0437\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430\u043c\u0438 \u043c\u0435\u0442\u043e\u0434 <code>filter()<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0443\u0436\u0435 <code>FluxFilter<\/code>, \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u043c \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u044b\u0448\u0435\u0441\u0442\u043e\u044f\u0449\u0438\u0439 flux (\u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 &#8212; <code>FluxArray<\/code>). \u0412\u044b\u0437\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430\u043c\u0438 \u0434\u0430\u043b\u0435\u0435 map() \u0432 \u044d\u0442\u043e\u043c \u043f\u043b\u0430\u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a\u043e\u0435 \u0436\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435, \u043d\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0443\u0436\u0435 <code>FluxMap<\/code> (\u0430 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u043c \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>FluxFilter<\/code>).<\/p>\n<p>\u0414\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043c\u043e\u0433\u043b\u043e \u0431\u044b \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0432\u0441\u0435 \u0432\u044b\u0448\u0435\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u0431\u0435\u0437 \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u0430:<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0441\u0435\u0432\u0434\u043e\u043a\u043e\u0434: \u044d\u0442\u0430\u043f \u0441\u0431\u043e\u0440\u043a\u0438<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">Flux&lt;Integer> sourceFlux = Flux.fromArray(array); Flux&lt;Integer> filterFlux = new FluxFilter(sourceFlux, i -> i \/ 2 != 0); Flux&lt;Integer> mapFlux = new FluxMap(filterFlux, i -> \"Number \" + i + \" is prime: \" + checker.isPrimeNumber(i));<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0439 flux \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u043c \u043f\u0441\u0435\u0432\u0434\u043e\u043a\u043e\u0434\u043e\u043c:  <code>FluxMap(FluxFilter(FluxArray(source)))<\/code><\/p>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041d\u0430 \u0432\u044b\u0437\u043e\u0432\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 <code>subscribe()<\/code> \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u0430\u043f \u0441\u0431\u043e\u0440\u043a\u0438 \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u0430\u043f \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438. <\/p>\n<details class=\"spoiler\">\n<summary>\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0432 \u043e subscribe()<\/summary>\n<div class=\"spoiler__content\">\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043c\u044b \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u044d\u0442\u0430\u043f\u0443 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438, \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0432 \u043e \u0441\u0430\u043c\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435 <code>subscribe()<\/code>.<\/p>\n<p>\u0423\u0441\u043b\u043e\u0432\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 <code>subscribe()<\/code> \u0432 \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 2 \u0447\u0430\u0441\u0442\u0438: \u043c\u0435\u0442\u043e\u0434\u044b, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0438\u0445 \u043b\u044f\u043c\u0431\u0434\u044b \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u0438\u0433\u043d\u0430\u043b\u043e\u0432 \u0441\u0442\u0440\u0438\u043c\u0430, \u0438 \u043c\u0435\u0442\u043e\u0434, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0438\u0439 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e <code>CoreSubscriber<\/code>.\u00a0<\/p>\n<p>\u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0438\u0433\u043d\u0430\u043b\u043e\u0432 \u0441\u0442\u0440\u0438\u043c\u0430 \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u0446\u0438\u044f\u0445: \u043e\u0434\u043d\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e (\u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432), \u0434\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (\u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u043e\u0448\u0438\u0431\u043e\u043a), \u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (\u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u043e\u0448\u0438\u0431\u043e\u043a \u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043f\u0440\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u0441\u0442\u0440\u0438\u043c\u0430) \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u0412\u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u0438\u0437 \u043d\u0438\u0445 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f <code>LambdaSubscriber<\/code>.<\/p>\n<p>\u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u0432\u043e\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e <code>CoreSubscriber<\/code>. \u0414\u043b\u044f \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <code>BaseSubscriber<\/code>, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0440\u0435\u0430\u043a\u0442\u043e\u0440\u043e\u043c.<\/p>\n<p>\u041e\u0442\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434 <code>subscribe()<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u0430\u043c \u043e\u0431\u044a\u0435\u043a\u0442 <code>Disposable<\/code>, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0442\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0443 \u043d\u0430 \u0441\u0442\u0440\u0438\u043c &#171;\u0441\u043d\u0430\u0440\u0443\u0436\u0438&#187;.<\/p>\n<\/div>\n<\/details>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>subscribe()<\/code> \u0434\u043b\u044f &#171;\u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u044e\u0449\u0438\u0445&#187; flux \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0432 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 <code>InternalFluxOperator<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043d\u0438 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442. \u0412\u043d\u0443\u0442\u0440\u0438 \u043d\u0435\u0433\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u043e\u0432\u043e\u0435 &#171;\u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u0435&#187;, \u0443\u0436\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u0432: \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e &#171;\u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e&#187; flux \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u0432\u043e\u044f \u0432\u0435\u0440\u0441\u0438\u044f <code>CoreSubscriber<\/code> (\u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e <code>FilterSubscriber<\/code> \u0438 <code>MapSubscriber<\/code>). \u0423\u0441\u043b\u043e\u0432\u043d\u044b\u043c \u043f\u0441\u0435\u0432\u0434\u043e\u043a\u043e\u0434\u043e\u043c \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a:<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0441\u0435\u0432\u0434\u043e\u043a\u043e\u0434: \u044d\u0442\u0430\u043f \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">mapFlux.subscribe(Subscriber){ MapSubscriber mapSubscriber = new MapSubscriber(Subscriber); filterFlux.subscribe(mapSubscriber) { FilterSubscriber filterSubscriber = new FilterSubscriber(mapSubscriber); arrayFlux.subscribe(filterSubscriber) { \/\/ \u0420\u0435\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0430 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 } } } <\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e Subscriber \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u043c \u043f\u0441\u0435\u0432\u0434\u043e\u043a\u043e\u0434\u043e\u043c: <code>FilterSubscriber(MapSubscriber(Subscriber))<\/code><\/p>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u0430\u043f \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u0430\u043f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u0442\u043e\u043a\u0430.<\/p>\n<p>&#171;\u041f\u043e\u0440\u043e\u0436\u0434\u0430\u044e\u0449\u0438\u0435&#187; flux \u043d\u0435 \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u044e\u0442 <code>Subscriber<\/code> &#8212; \u043e\u043d\u0438 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442 \u0443 \u043d\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434 <code>onSibscribe()<\/code> \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442 \u0432 \u043d\u0435\u0433\u043e \u0441\u0432\u043e\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e <code>Subscription<\/code>. \u041a\u0430\u0436\u0434\u044b\u0439 &#171;\u043f\u043e\u0440\u043e\u0436\u0434\u0430\u044e\u0449\u0438\u0439&#187; flux \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u043e\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e <code>Subscription<\/code>: <code>ArraySubscription<\/code>, <code>IterableSubscription<\/code>, <code>StreamSubscription<\/code>, <code>RangeSubscription<\/code> \u0438 \u0442.\u0434. \u041a\u0430\u0436\u0434\u044b\u0439 <code>Subscriber<\/code> \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>onSibscribe()<\/code> \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0443 \u0441\u0435\u0431\u044f \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 <code>Subscription<\/code> \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0435\u0435 \u0432\u044b\u0448\u0435\u0441\u0442\u043e\u044f\u0449\u0435\u043c\u0443 \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u0443, \u0432\u043f\u043b\u043e\u0442\u044c \u0434\u043e \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 <code>onSubscribe()<\/code> \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0430 \u0438\u043c\u0435\u043d\u043d\u043e &#8212; \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 <code>Subscription.request()<\/code>) \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0442\u0440\u0438\u043c \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u0430\u043b.\u00a0<\/p>\n<details class=\"spoiler\">\n<summary>LambdaSubscriber \u043a\u0430\u043a \u043f\u0440\u0438\u043c\u0435\u0440<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>Consumer&lt;Subscription><\/code> \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u0441\u0442\u0440\u0438\u043c\u0430 &#8212; \u0432\u044b\u0437\u043e\u0432\u0435\u0442\u0441\u044f \u043e\u043d\u0430 (<code>subscriptionConsumer<\/code> \u0432 \u043a\u043e\u0434\u0435), \u0438\u043d\u0430\u0447\u0435 <code>LambdaSubscriber<\/code> \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u043c\u0435\u0440\u0435 \u0438\u0445 \u043f\u043e\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"java\">  public final void onSubscribe(Subscription s) {       if (Operators.validate(subscription, s)) {           this.subscription = s;           if (subscriptionConsumer != null) {               try {                   subscriptionConsumer.accept(s);               }               catch (Throwable t) {                   Exceptions.throwIfFatal(t);                   s.cancel();                   onError(t);               }           }           else {               <\/code><\/pre>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-340091","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/340091","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=340091"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/340091\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=340091"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=340091"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=340091"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}