{"id":340513,"date":"2022-10-31T15:00:23","date_gmt":"2022-10-31T15:00:23","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=340513"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=340513","title":{"rendered":"<span>\u041f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043e\u0432 \u0432 Apache Camel \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 Direct<\/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<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0431\u044b \u0445\u043e\u0442\u0435\u043b \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u044c \u0442\u0435\u043c\u0443 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043e\u0432 \u0432 Apache Camel \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 Direct.<\/p>\n<h2>\u041f\u0440\u0438\u043c\u0435\u0440 \u0437\u0430\u0434\u0430\u0447\u0438<\/h2>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u043c\u0438 \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u0434\u0430\u0447\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043e\u0432 \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0430\u043c\u0438:<\/p>\n<ol>\n<li>\n<p>\u0412\u0445\u043e\u0434\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430 &#8212; REST.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 throttling \u0438\u043b\u0438 rate limiting \u043f\u043e\u043b\u0438\u0442\u0438\u043a \u043d\u0430 \u0432\u0445\u043e\u0434\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0435 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044f (header, body \u0438 \u0442.\u0434.).<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 throttling \u0438\u043b\u0438 rate limiting \u043f\u043e\u043b\u0438\u0442\u0438\u043a \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u0432\u0435\u0442\u043e\u043a \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e.<\/p>\n<\/li>\n<\/ol>\n<h2>\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u043f\u0443\u0442\u0435\u0439 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u0445. \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0430\u043a\u043e\u0433\u043e \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 Apache Camel &#8212; Direct.<\/p>\n<blockquote>\n<p>\u0418\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Apache Camel: \u201cThis endpoint can be used to connect existing routes in the same camel context.\u201d<\/p>\n<\/blockquote>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h2>\n<blockquote>\n<p>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u0434\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u043e \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0430 \u0434\u043b\u044f Apache Camel \u0432\u0435\u0440\u0441\u0438\u0439 3.12-3.19<\/p>\n<\/blockquote>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441 ComplexRouteBuilder, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u043e\u043c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 RouteBuilder \u0438 \u043e\u0431\u044a\u044f\u0432\u0438\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u0435\u0442\u043e\u0434\u0430 configure().<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u0435\u0442\u043e\u0434 configure() \u0443\u0436\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u044b\u0437\u043e\u0432\u044b \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0433\u043e \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"java\">private static final List&lt;String> CHOICE_ROUTES_NAMES = Arrays.asList(\"choice_1\", \"choice_2\", \"choice_3\");  @Override public void configure() throws Exception {     defineInitialStep();     defineThrottlingStep();     defineChoiceStep();     defineDestinationStep(); }<\/code><\/pre>\n<h3>\u0422\u043e\u0447\u043a\u0430 \u0432\u0445\u043e\u0434\u0430 \u0432 \u043c\u0430\u0440\u0448\u0440\u0443\u0442<\/h3>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0442\u043e\u0447\u043a\u0438 \u0432\u0445\u043e\u0434\u0430 \u043e\u0431\u044a\u044f\u0432\u0438\u043c \u043c\u0430\u0440\u0448\u0440\u0443\u0442, \u0441\u043b\u0443\u0448\u0430\u044e\u0449\u0438\u0439 REST \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 {contextPath}\/api\/complex_route \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0449\u0438\u0439 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0434\u0430\u043b\u044c\u0448\u0435 \u0432 <strong>direct:throttling<\/strong>.<\/p>\n<pre><code class=\"java\">private void defineInitialStep() {     var firstPartRouteDefinition = rest(\"\/api\")             .get(\"\/complex_route\")             .to(\"direct:throttling\"); }<\/code><\/pre>\n<h3>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043d\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0432\u0441\u0435\u0433\u043e \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430<\/h3>\n<p>\u0414\u043b\u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043d\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u043e\u0431\u044a\u044f\u0432\u0438\u043c \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0439 \u0448\u0430\u0433, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c Throttling Policy. \u0422\u043e\u0447\u043a\u0430 \u0432\u0445\u043e\u0434\u0430 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 &#8212; <strong>direct:throttling<\/strong>, \u0432\u044b\u0445\u043e\u0434 &#8212; <strong>direct:choice<\/strong>.<\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043d\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0430 &#8212; \u0432\u044b\u043d\u0435\u0441\u0435\u043c \u0434\u0430\u043d\u043d\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434.<\/p>\n<pre><code class=\"java\">    private void defineThrottlingStep() {         var throttlingPartRouteDefinition = from(\"direct:throttling\")                 .to(\"direct:choice\");         applyThrottlingPolicy(throttlingPartRouteDefinition);     }          private void applyThrottlingPolicy(RouteDefinition routeDefinition) {         routeDefinition                 .throttle(10)                 .timePeriodMillis(1000)                 .rejectExecution(true)                 .onException(ThrottlerRejectedExecutionException.class)                     .to(\"bean:logger\")                     .handled(true)                     .process(\"routeErrorProcessor\")                     .stop()                 .end();     }<\/code><\/pre>\n<h3>\u0412\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430<\/h3>\n<p>\u041c\u0430\u0440\u0448\u0440\u0443\u0442 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043b\u0443\u0448\u0430\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0438\u0437 <strong>direct:choice<\/strong> \u0438, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 \u0432 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0445 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043c\u0430\u0440\u0448\u0440\u0443\u0442 <strong>direct:{choice_route_name}_destination<\/strong>.<\/p>\n<pre><code class=\"java\">private void defineChoiceStep() {     var choicePartRouteDefinition = from(\"direct:choice\");     var choiceDefinition = choicePartRouteDefinition.choice();     CHOICE_ROUTES_NAMES.forEach(o -> {         Predicate choicePredicate = header(o).isEqualTo(o + \" header value\");         choicePartRouteDefinition.choice().when(choicePredicate)                 .to(\"direct:\" + o + \"_destination\");     });     choiceDefinition.endChoice(); }<\/code><\/pre>\n<h3>\u0422\u043e\u0447\u043a\u0430 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/h3>\n<p>\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043c\u0430\u0440\u0448\u0440\u0443\u0442, \u0432\u0435\u0434\u0443\u0449\u0438\u0439 \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u044b \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043e\u0432 \u0442\u043e\u0447\u043a\u043e\u0439 \u0432\u0445\u043e\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 <strong>direct:{choice_route_name}_destination<\/strong>, \u0430 \u0442\u043e\u0447\u043a\u043e\u0439 \u0432\u044b\u0445\u043e\u0434\u0430 &#8212; <strong>http \u0430\u0434\u0440\u0435\u0441<\/strong> \u043d\u0430 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u0435.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u0438\u0437 \u044d\u0442\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c ThrottlingPolicy \u0434\u043b\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0441\u0442\u0432\u0438\u044f \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0443\u0441\u043b\u043e\u0432\u0438\u044e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043d\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u0435\u0442\u0432\u0438 (\u043a\u043e\u0434 \u043c\u0435\u0442\u043e\u0434\u0430 applyThrottlingPolicy \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043b\u0441\u044f \u0432\u044b\u0448\u0435).<\/p>\n<pre><code class=\"java\">private void defineDestinationStep() {     CHOICE_ROUTES_NAMES.forEach(o -> {         var destinationRouteDefinition = from(\"direct:\" + o + \"_destination\")                 .to(\"http:\/\/localhost:9191\/api\/v1\/test\/first?bridgeEndpoint=true&amp;someParam=\" + o);         applyThrottlingPolicy(destinationRouteDefinition);     }); }<\/code><\/pre>\n<h3>\u0421\u0445\u0435\u043c\u0430 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u0438\u0437 \u043f\u0440\u0438\u043c\u0435\u0440\u0430<\/h3>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/95a\/bfe\/758\/95abfe758c9faecab1ec4af5653ffdb2.png\" width=\"1717\" height=\"645\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/95a\/bfe\/758\/95abfe758c9faecab1ec4af5653ffdb2.png\"\/><figcaption><\/figcaption><\/figure>\n<h2>\u0418\u0442\u043e\u0433<\/h2>\n<p>\u041f\u043e \u0438\u0442\u043e\u0433\u0443 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u043c\u044b \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043b\u0438 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043d\u044b\u0439 \u043c\u0430\u0440\u0448\u0440\u0443\u0442 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043f\u0440\u0430\u0432\u0438\u043b.<\/p>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u043a\u0430\u043a \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0438\u0442\u0438\u043a \u0438 \u043f\u0440\u0430\u0432\u0438\u043b \u0442\u0430\u043a \u0438 \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0438\u0445 \u0443\u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<h3>\u041f\u043b\u044e\u0441\u044b<\/h3>\n<ol>\n<li>\n<p>\u0421\u043b\u0430\u0431\u0430\u044f \u0441\u0432\u044f\u0437\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0439 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0445 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043e\u0432. \u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0433\u0438\u0431\u043a\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434.<\/p>\n<\/li>\n<li>\n<p>\u0423\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u043a\u043e\u0434\u0430 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 Single Responsibility. \u0427\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u0437\u0430 \u0435\u0433\u043e \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e\u043c.<\/p>\n<\/li>\n<li>\n<p>\u041c\u0435\u043d\u044c\u0448\u0430\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0434\u043b\u044f \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439.<\/p>\n<\/li>\n<\/ol>\n<h3>\u041c\u0438\u043d\u0443\u0441\u044b<\/h3>\n<ol>\n<li>\n<p>\u0421\u043b\u0430\u0431\u0430\u044f \u0441\u0432\u044f\u0437\u043d\u043e\u0441\u0442\u044c \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u0437\u0430 \u0441\u043e\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0435\u043c \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438. \u041d\u0430 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u044d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a \u0437\u0430\u043c\u0435\u0442\u043d\u043e. \u041d\u043e \u0432 \u0446\u0435\u043b\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0445 \u0437\u0432\u0435\u043d\u044c\u0435\u0432-\u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043e\u0432 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u0438. \u0412 \u043a\u0430\u043a\u043e\u043c \u0438\u043c\u0435\u043d\u043d\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0435 \u0438 \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u0432\u043b\u0438\u044f\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c &#8212; \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u044f \u043d\u0435 \u0437\u043d\u0430\u044e.<\/p>\n<\/li>\n<\/ol>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435.<\/p>\n<\/p>\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\/696530\/\"> https:\/\/habr.com\/ru\/post\/696530\/<\/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<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0431\u044b \u0445\u043e\u0442\u0435\u043b \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u044c \u0442\u0435\u043c\u0443 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043e\u0432 \u0432 Apache Camel \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 Direct.<\/p>\n<h2>\u041f\u0440\u0438\u043c\u0435\u0440 \u0437\u0430\u0434\u0430\u0447\u0438<\/h2>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u043c\u0438 \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u0434\u0430\u0447\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043e\u0432 \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0430\u043c\u0438:<\/p>\n<ol>\n<li>\n<p>\u0412\u0445\u043e\u0434\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430 &#8212; REST.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 throttling \u0438\u043b\u0438 rate limiting \u043f\u043e\u043b\u0438\u0442\u0438\u043a \u043d\u0430 \u0432\u0445\u043e\u0434\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0435 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044f (header, body \u0438 \u0442.\u0434.).<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 throttling \u0438\u043b\u0438 rate limiting \u043f\u043e\u043b\u0438\u0442\u0438\u043a \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u0432\u0435\u0442\u043e\u043a \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e.<\/p>\n<\/li>\n<\/ol>\n<h2>\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u043f\u0443\u0442\u0435\u0439 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u0445. \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0430\u043a\u043e\u0433\u043e \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 Apache Camel &#8212; Direct.<\/p>\n<blockquote>\n<p>\u0418\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Apache Camel: \u201cThis endpoint can be used to connect existing routes in the same camel context.\u201d<\/p>\n<\/blockquote>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h2>\n<blockquote>\n<p>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u0434\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u043e \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0430 \u0434\u043b\u044f Apache Camel \u0432\u0435\u0440\u0441\u0438\u0439 3.12-3.19<\/p>\n<\/blockquote>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441 ComplexRouteBuilder, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u043e\u043c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 RouteBuilder \u0438 \u043e\u0431\u044a\u044f\u0432\u0438\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u0435\u0442\u043e\u0434\u0430 configure().<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u0435\u0442\u043e\u0434 configure() \u0443\u0436\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u044b\u0437\u043e\u0432\u044b \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0433\u043e \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"java\">private static final List&lt;String> CHOICE_ROUTES_NAMES = Arrays.asList(\"choice_1\", \"choice_2\", \"choice_3\");  @Override public void configure() throws Exception {     defineInitialStep();     defineThrottlingStep();     defineChoiceStep();     defineDestinationStep(); }<\/code><\/pre>\n<h3>\u0422\u043e\u0447\u043a\u0430 \u0432\u0445\u043e\u0434\u0430 \u0432 \u043c\u0430\u0440\u0448\u0440\u0443\u0442<\/h3>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0442\u043e\u0447\u043a\u0438 \u0432\u0445\u043e\u0434\u0430 \u043e\u0431\u044a\u044f\u0432\u0438\u043c \u043c\u0430\u0440\u0448\u0440\u0443\u0442, \u0441\u043b\u0443\u0448\u0430\u044e\u0449\u0438\u0439 REST \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 {contextPath}\/api\/complex_route \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0449\u0438\u0439 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0434\u0430\u043b\u044c\u0448\u0435 \u0432 <strong>direct:throttling<\/strong>.<\/p>\n<pre><code class=\"java\">private void defineInitialStep() {     var firstPartRouteDefinition = rest(\"\/api\")             .get(\"\/complex_route\")             .to(\"direct:throttling\"); }<\/code><\/pre>\n<h3>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043d\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0432\u0441\u0435\u0433\u043e \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430<\/h3>\n<p>\u0414\u043b\u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043d\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u043e\u0431\u044a\u044f\u0432\u0438\u043c \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0439 \u0448\u0430\u0433, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c Throttling Policy. \u0422\u043e\u0447\u043a\u0430 \u0432\u0445\u043e\u0434\u0430 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 &#8212; <strong>direct:throttling<\/strong>, \u0432\u044b\u0445\u043e\u0434 &#8212; <strong>direct:choice<\/strong>.<\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043d\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0430 &#8212; \u0432\u044b\u043d\u0435\u0441\u0435\u043c \u0434\u0430\u043d\u043d\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434.<\/p>\n<pre><code class=\"java\">    private void defineThrottlingStep() {         var throttlingPartRouteDefinition = from(\"direct:throttling\")                 .to(\"direct:choice\");         applyThrottlingPolicy(throttlingPartRouteDefinition);     }          private void applyThrottlingPolicy(RouteDefinition routeDefinition) {         routeDefinition                 .throttle(10)                 .timePeriodMillis(1000)                 .rejectExecution(true)                 .onException(ThrottlerRejectedExecutionException.class)                     .to(\"bean:logger\")                     .handled(true)                     .process(\"routeErrorProcessor\")                     .stop()                 .end();     }<\/code><\/pre>\n<h3>\u0412\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430<\/h3>\n<p>\u041c\u0430\u0440\u0448\u0440\u0443\u0442 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043b\u0443\u0448\u0430\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0438\u0437 <strong>direct:choice<\/strong> \u0438, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 \u0432 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0445 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043c\u0430\u0440\u0448\u0440\u0443\u0442 <strong>direct:{choice_route_name}_destination<\/strong>.<\/p>\n<pre><code class=\"java\">private void defineChoiceStep() {     var choicePartRouteDefinition = from(\"direct:choice\");     var choiceDefinition = choicePartRouteDefinition.choice();     CHOICE_ROUTES_NAMES.forEach(o -> {         Predicate choicePredicate = header(o).isEqualTo(o + \" header value\");         choicePartRouteDefinition.choice().when(choicePredicate)                 .to(\"direct:\" + o + \"_destination\");     });     choiceDefinition.endChoice(); }<\/code><\/pre>\n<h3>\u0422\u043e\u0447\u043a\u0430 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/h3>\n<p>\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043c\u0430\u0440\u0448\u0440\u0443\u0442, \u0432\u0435\u0434\u0443\u0449\u0438\u0439 \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u044b \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043e\u0432 \u0442\u043e\u0447\u043a\u043e\u0439 \u0432\u0445\u043e\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 <strong>direct:{choice_route_name}_destination<\/strong>, \u0430 \u0442\u043e\u0447\u043a\u043e\u0439 \u0432\u044b\u0445\u043e\u0434\u0430 &#8212; <strong>http \u0430\u0434\u0440\u0435\u0441<\/strong> \u043d\u0430 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u0435.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u0438\u0437 \u044d\u0442\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c ThrottlingPolicy \u0434\u043b\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0441\u0442\u0432\u0438\u044f \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0443\u0441\u043b\u043e\u0432\u0438\u044e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043d\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u0435\u0442\u0432\u0438 (\u043a\u043e\u0434 \u043c\u0435\u0442\u043e\u0434\u0430 applyThrottlingPolicy \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043b\u0441\u044f \u0432\u044b\u0448\u0435).<\/p>\n<pre><code class=\"java\">private void defineDestinationStep() {     CHOICE_ROUTES_NAMES.forEach(o -> {         var destinationRouteDefinition = from(\"direct:\" + o + \"_destination\")                 .to(\"http:\/\/localhost:9191\/api\/v1\/test\/first?bridgeEndpoint=true&amp;someParam=\" + o);         applyThrottlingPolicy(destinationRouteDefinition);     }); }<\/code><\/pre>\n<h3>\u0421\u0445\u0435\u043c\u0430 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u0438\u0437 \u043f\u0440\u0438\u043c\u0435\u0440\u0430<\/h3>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h2>\u0418\u0442\u043e\u0433<\/h2>\n<p>\u041f\u043e \u0438\u0442\u043e\u0433\u0443 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u043c\u044b \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043b\u0438 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043d\u044b\u0439 \u043c\u0430\u0440\u0448\u0440\u0443\u0442 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043f\u0440\u0430\u0432\u0438\u043b.<\/p>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u043a\u0430\u043a \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0438\u0442\u0438\u043a \u0438 \u043f\u0440\u0430\u0432\u0438\u043b \u0442\u0430\u043a \u0438 \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0438\u0445 \u0443\u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<h3>\u041f\u043b\u044e\u0441\u044b<\/h3>\n<ol>\n<li>\n<p>\u0421\u043b\u0430\u0431\u0430\u044f \u0441\u0432\u044f\u0437\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0439 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0445 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043e\u0432. \u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0433\u0438\u0431\u043a\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434.<\/p>\n<\/li>\n<li>\n<p>\u0423\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u043a\u043e\u0434\u0430 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 Single Responsibility. \u0427\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u0437\u0430 \u0435\u0433\u043e \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e\u043c.<\/p>\n<\/li>\n<li>\n<p>\u041c\u0435\u043d\u044c\u0448\u0430\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0434\u043b\u044f \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439.<\/p>\n<\/li>\n<\/ol>\n<h3>\u041c\u0438\u043d\u0443\u0441\u044b<\/h3>\n<ol>\n<li>\n<p>\u0421\u043b\u0430\u0431\u0430\u044f \u0441\u0432\u044f\u0437\u043d\u043e\u0441\u0442\u044c \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u0437\u0430 \u0441\u043e\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0435\u043c \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438. \u041d\u0430 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u044d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a \u0437\u0430\u043c\u0435\u0442\u043d\u043e. \u041d\u043e \u0432 \u0446\u0435\u043b\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0445 \u0437\u0432\u0435\u043d\u044c\u0435\u0432-\u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043e\u0432 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u0438. \u0412 \u043a\u0430\u043a\u043e\u043c \u0438\u043c\u0435\u043d\u043d\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0435 \u0438 \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u0432\u043b\u0438\u044f\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c &#8212; \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u044f \u043d\u0435 \u0437\u043d\u0430\u044e.<\/p>\n<\/li>\n<\/ol>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435.<\/p>\n<\/p>\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\/696530\/\"> https:\/\/habr.com\/ru\/post\/696530\/<\/a><br \/><\/br><\/br><\/p>\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-340513","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/340513","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=340513"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/340513\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=340513"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=340513"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=340513"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}