{"id":294780,"date":"2019-11-18T09:00:49","date_gmt":"2019-11-18T09:00:49","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=294780"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=294780","title":{"rendered":"\u0421\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0417\u0430\u043f\u0440\u043e\u0441-\u041e\u0442\u0432\u0435\u0442 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Apache Kafka"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\"><a href=\"https:\/\/martinfowler.com\/articles\/201701-event-driven.html\">\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b, \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u043c\u0438 (Event Driven Architecture)<\/a>, \u0432 \u0446\u0435\u043b\u043e\u043c, \u0438 <a href=\"https:\/\/kafka.apache.org\/\">Apache Kafka<\/a>, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u043b\u0438 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435. \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0441\u0435\u0445 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b, \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0439 \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u043c\u0438, \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u043e \u0441\u0432\u043e\u0435\u0439 \u0441\u0443\u0442\u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u043c\u043e\u0433\u0443\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0441\u043e\u0431\u044b\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438\/\u043f\u043e\u0442\u043e\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u043a\u0430 <b>\u0421\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u0417\u0430\u043f\u0440\u043e\u0441\u0430-\u041e\u0442\u0432\u0435\u0442\u0430<\/b>. \u0412 \u044d\u0442\u043e\u043c \u0432\u044b\u043f\u0443\u0441\u043a\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e, \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c <b>&#171;<a href=\"https:\/\/www.enterpriseintegrationpatterns.com\/patterns\/messaging\/RequestReply.html\">\u0417\u0430\u043f\u0440\u043e\u0441-\u041e\u0442\u0432\u0435\u0442<\/a>&#171;<\/b> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <b>Apache Kafka<\/b>.<\/p>\n<p>  \u041f\u0435\u0440\u0435\u0432\u0435\u043b <b><a href=\"http:\/\/tele.gg\/middle_java\">@middle_java<\/a><\/b><br \/>  <a name=\"habracut\"><\/a><br \/>  \u0414\u0430\u0442\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438: 26 October 2018<\/p>\n<p>  Apache Kafka \u043f\u043e \u0441\u0432\u043e\u0435\u0439 \u043f\u0440\u0438\u0440\u043e\u0434\u0435 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430. \u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u043a\u0430 <b>\u00ab\u0417\u0430\u043f\u0440\u043e\u0441-\u041e\u0442\u0432\u0435\u0442\u00bb<\/b> \u0434\u043b\u044f Apache Kafka \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u044d\u0442\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u043d\u0435 \u043d\u043e\u0432\u0430. \u041f\u0430\u0442\u0442\u0435\u0440\u043d \u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 \u041a\u043e\u0440\u043f\u043e\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 (Enterprise Integration Pattern) <b><a href=\"https:\/\/www.enterpriseintegrationpatterns.com\/patterns\/messaging\/RequestReply.html\">Request-Reply<\/a><\/b> \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u043c\u0435\u043d\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c\u0438 \u043f\u043e \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c \u043a\u0430\u043d\u0430\u043b\u0430\u043c:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ww\/cy\/0h\/wwcy0hvrj6iie7amwxpk1twfbui.gif\"><\/p>\n<p>  \u041f\u0430\u0442\u0442\u0435\u0440\u043d <b><a href=\"https:\/\/www.enterpriseintegrationpatterns.com\/patterns\/messaging\/ReturnAddress.html\">Return Address (\u0410\u0434\u0440\u0435\u0441 \u0412\u043e\u0437\u0432\u0440\u0430\u0442\u0430)<\/a><\/b> \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043f\u0430\u0442\u0442\u0435\u0440\u043d <b><a href=\"https:\/\/www.enterpriseintegrationpatterns.com\/patterns\/messaging\/RequestReply.html\">Request-Reply<\/a><\/b> \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u043c \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u044e\u0449\u0435\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u043e\u0439 \u0430\u0434\u0440\u0435\u0441\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d \u043e\u0442\u0432\u0435\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/rw\/nd\/qq\/rwndqqxh42kt82xadcbvgjb76wa.gif\"><\/p>\n<p>  \u041d\u0435\u0434\u0430\u0432\u043d\u043e \u0432 <a href=\"https:\/\/spring.io\/projects\/spring-kafka\">Spring Kafka<\/a> <b>2.1.3<\/b> \u0431\u044b\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 \u00abRequest Reply\u00bb, \u0430 \u0432 \u0432\u0435\u0440\u0441\u0438\u0438 <b>2.2<\/b> \u0431\u044b\u043b\u0438 \u043e\u0442\u043f\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u0435\u0433\u043e \u0448\u0435\u0440\u043e\u0445\u043e\u0432\u0430\u0442\u043e\u0441\u0442\u0435\u0439. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u044d\u0442\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430:<\/p>\n<h2>\u041d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430: ReplyingKafkaTemplate<\/h2>\n<p>  \u0425\u043e\u0440\u043e\u0448\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430\u044f \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044f <b>Template (\u0428\u0430\u0431\u043b\u043e\u043d)<\/b> \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0432 Spring \u043e\u0441\u043d\u043e\u0432\u0443 \u0434\u043b\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 Request-Reply.<\/p>\n<pre><code class=\"java\"> @Bean  public ReplyingKafkaTemplate &lt; String, Request, Reply &gt; replyKafkaTemplate(      ProducerFactory &lt; String, Request &gt; pf,      KafkaMessageListenerContainer &lt; String, Reply &gt; lc) {      return new ReplyingKafkaTemplate &lt; &gt; (pf, lc);  }<\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u0432\u0441\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u044f\u043c\u043e\u043b\u0438\u043d\u0435\u0439\u043d\u043e: \u043c\u044b \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c <b>ReplyingKafkaTemplate<\/b>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0441\u043e String \u043a\u043b\u044e\u0447\u0430\u043c\u0438 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f-\u043e\u0442\u0432\u0435\u0442\u044b \u0441\u043e String \u043a\u043b\u044e\u0447\u0430\u043c\u0438. \u0412\u043c\u0435\u0441\u0442\u0435 \u0441 \u0442\u0435\u043c ReplyingKafkaTemplate \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 ProducerFactory \u0417\u0430\u043f\u0440\u043e\u0441\u0430, ConsumerFactory \u041e\u0442\u0432\u0435\u0442\u0430 \u0438 MessageListenerContainer \u0441 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f\u043c\u0438 \u043a\u043e\u043d\u0441\u044e\u043c\u0435\u0440\u0430 \u0438 \u043f\u0440\u043e\u0434\u044e\u0441\u0435\u0440\u0430. \u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u0432\u0435\u0441\u0438\u0441\u0442\u0430:<\/p>\n<pre><code class=\"java\"> @Value(\"${kafka.topic.car.reply}\")  private String replyTopic;   @Bean  public Map &lt; String, Object &gt; consumerConfigs() {      Map &lt; String, Object &gt; props = new HashMap &lt; &gt; ();      props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);      props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);      props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, JsonDeserializer.class);      props.put(ConsumerConfig.GROUP_ID_CONFIG, groupId);       return props;  }   @Bean  public Map &lt; String, Object &gt; producerConfigs() {      Map &lt; String, Object &gt; props = new HashMap &lt; &gt; ();      props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);      props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);      props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, JsonSerializer.class);      return props;  }   @Bean  public ProducerFactory &lt; String, Request &gt; requestProducerFactory() {      return new DefaultKafkaProducerFactory &lt; &gt; (producerConfigs());  }   @Bean  public ConsumerFactory &lt; String, Reply &gt; replyConsumerFactory() {      return new DefaultKafkaConsumerFactory &lt; &gt; (consumerConfigs(), new StringDeserializer(),          new JsonSerializer &lt; Reply &gt; ());  }   @Bean  public KafkaMessageListenerContainer &lt; String, Reply &gt; replyListenerContainer() {      ContainerProperties containerProperties = new ContainerProperties(replyTopic);      return new KafkaMessageListenerContainer &lt; &gt; (replyConsumerFactory(), containerProperties);  }<\/code><\/pre>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <b>replyKafkaTemplate <\/b>\u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u0442\u0432\u0435\u0442\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"java\">@Value(\"${kafka.topic.car.request}\") private String requestTopic;  @Value(\"${kafka.topic.car.reply}\") private String replyTopic;  @Autowired private ReplyingKafkaTemplate &lt; String, Request, Reply &gt; requestReplyKafkaTemplate;  ... RequestReply request = RequestReply.request(...); \/\/\u0441\u043e\u0437\u0434\u0430\u0435\u043c producer record ProducerRecord &lt; String, Request &gt; record = new ProducerRecord &lt; String, Request &gt; (requestTopic, request); \/\/ \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0442\u043e\u043f\u0438\u043a \u0434\u043b\u044f \u043e\u0442\u0432\u0435\u0442\u0430 \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435 record.headers().add(new RecordHeader(KafkaHeaders.REPLY_TOPIC, requestReplyTopic.getBytes())); \/\/ \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 \u0442\u043e\u043f\u0438\u043a Kafka \u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0442\u0432\u0435\u0442 \u0432 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0442\u043e\u043f\u0438\u043a \u0434\u043b\u044f \u043e\u0442\u0432\u0435\u0442\u0430 RequestReplyFuture &lt; String, Request, Reply &gt; sendAndReceive = requestReplyKafkaTemplate.sendAndReceive(record); sendAndReceive.addCallback(new ListenableFutureCallback &lt; ConsumerRecord &lt; String, Reply &gt;&gt; () {     @Override     public void onSuccess(ConsumerRecord &lt; String, Reply &gt; result) {         \/\/ \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 consumer record         Reply reply = result.value();         System.out.println(\"Reply: \" + reply.toString());     } });<\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u0442\u0430\u043a\u0436\u0435 \u043c\u043d\u043e\u0433\u043e \u0431\u043e\u0439\u043b\u0435\u0440\u043f\u043b\u0435\u0439\u0442\u0430 \u0438 \u043d\u0438\u0437\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u043e\u0433\u043e API, \u0434\u0430 \u0435\u0449\u0435 \u044d\u0442\u043e\u0442 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u0439 API <b>ListenableFuture <\/b>\u0432\u043c\u0435\u0441\u0442\u043e \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <b>CompletableFuture<\/b>.<\/p>\n<p>  <b>requestReplyKafkaTemplate <\/b>\u0437\u0430\u0431\u043e\u0442\u0438\u0442\u0441\u044f \u043e \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430 <b>KafkaHeaders.CORRELATION_ID<\/b>, \u043d\u043e \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u044f\u0432\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a <b>KafkaHeaders.REPLY_TOPIC<\/b> \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0442\u0430\u043a\u0436\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u0436\u0435 \u0442\u043e\u043f\u0438\u043a \u0434\u043b\u044f \u043e\u0442\u0432\u0435\u0442\u0430 \u0431\u044b\u043b \u0438\u0437\u043b\u0438\u0448\u043d\u0435 \u0437\u0430\u0438\u043d\u0436\u0435\u043a\u0442\u0435\u043d \u0432\u044b\u0448\u0435 \u0432 <b>replyListenerContainer<\/b>. \u0413\u0430\u0434\u043e\u0441\u0442\u044c \u043a\u0430\u043a\u0430\u044f-\u0442\u043e. \u041d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0442\u043e, \u0447\u0435\u0433\u043e \u044f \u043e\u0436\u0438\u0434\u0430\u043b \u043e\u0442 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438 Spring.<\/p>\n<h2>\u0421\u0435\u0440\u0432\u0435\u0440\u043d\u0430\u044f \u0441\u0442\u043e\u0440\u043e\u043d\u0430: @SendTo<\/h2>\n<p>  \u041d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 <b>KafkaListener<\/b>, \u043f\u0440\u043e\u0441\u043b\u0443\u0448\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u0442\u043e\u043f\u0438\u043a \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0435\u0439 <b>@SendTo<\/b>, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435-\u043e\u0442\u0432\u0435\u0442. \u041e\u0431\u044a\u0435\u043a\u0442, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439 \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u044f, \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f (wrapped) \u0432 \u043e\u0442\u0432\u0435\u0442\u043d\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f <b>CORRELATION_ID<\/b> \u0438 \u043e\u0442\u0432\u0435\u0442 \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043f\u0438\u043a\u0435, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435 <b>REPLY_TOPIC<\/b>.<\/p>\n<pre><code class=\"java\"> @Bean  public Map &lt; String, Object &gt; consumerConfigs() {      Map &lt; String, Object &gt; props = new HashMap &lt; &gt; ();      props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);      props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);      props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, JsonSerializer.class);      props.put(ConsumerConfig.GROUP_ID_CONFIG, groupId);       return props;  }   @Bean  public Map &lt; String, Object &gt; producerConfigs() {      Map &lt; String, Object &gt; props = new HashMap &lt; &gt; ();      props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);      props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);      props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, JsonSerializer.class);       return props;  }   @Bean  public ConsumerFactory &lt; String, Request &gt; requestConsumerFactory() {      return new DefaultKafkaConsumerFactory &lt; &gt; (consumerConfigs(), new StringDeserializer(),          new JsonSerializer &lt; Request &gt; ());  }   @Bean  public KafkaListenerContainerFactory &lt; ConcurrentMessageListenerContainer &lt; String, Request &gt;&gt; requestListenerContainerFactory() {      ConcurrentKafkaListenerContainerFactory &lt; String, Request &gt; factory =          new ConcurrentKafkaListenerContainerFactory &lt; &gt; ();      factory.setConsumerFactory(requestConsumerFactory());      factory.setReplyTemplate(replyTemplate());      return factory;  }   @Bean  public ProducerFactory &lt; String, Reply &gt; replyProducerFactory() {      return new DefaultKafkaProducerFactory &lt; &gt; (producerConfigs());  }   @Bean  public KafkaTemplate &lt; String, Reply &gt; replyTemplate() {      return new KafkaTemplate &lt; &gt; (replyProducerFactory());  }<\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u0442\u0430\u043a\u0436\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f, \u043d\u043e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u044f \u043f\u0440\u043e\u0449\u0435:<\/p>\n<pre><code class=\"java\"> @KafkaListener(topics = \"${kafka.topic.car.request}\", containerFactory = \"requestListenerContainerFactory\")  @SendTo()  public Reply receive(Request request) {      Reply reply = ...;      return reply;  }<\/code><\/pre>\n<p>  <\/p>\n<h2>\u041d\u043e \u043a\u0430\u043a \u043d\u0430\u0441\u0447\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u043a\u043e\u043d\u0441\u044e\u043c\u0435\u0440\u0430?<\/h2>\n<p>  \u0412\u0441\u0435 \u0432\u0440\u043e\u0434\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043f\u043e\u043a\u0430 \u043c\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u043a\u043e\u043d\u0441\u044e\u043c\u0435\u0440\u0430. \u0415\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u043a\u043b\u0438\u0435\u043d\u0442\u0430, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043e\u0442\u0432\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0438\u0435\u043d\u0442\u0430. \u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f Spring Kafka \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442, \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u043e\u043d\u0441\u044e\u043c\u0435\u0440 \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u043e\u043f\u0438\u043a \u0438\u043b\u0438, \u0447\u0442\u043e \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430 <b>KafkaHeaders.RESPONSE_PARTITION<\/b> \u2014 \u0447\u0435\u0442\u044b\u0440\u0435\u0445\u0431\u0430\u0439\u0442\u043e\u0432\u043e\u0435 \u043f\u043e\u043b\u0435, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0435 BIG-ENDIAN-\u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043d\u043e\u043c\u0435\u0440\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0430. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0442\u043e\u043f\u0438\u043a\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u044f\u0432\u043d\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0433\u0438\u0431\u043a\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u044f\u0432\u043d\u0443\u044e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 <b>REPLY_PARTITION<\/b>. \u0422\u043e\u0433\u0434\u0430 \u043a\u043b\u0438\u0435\u043d\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u043d\u0430\u0442\u044c, \u043d\u0430 \u043a\u0430\u043a\u0443\u044e \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u044e \u043e\u043d \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d. \u0412 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044f\u0432\u043d\u0443\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0438. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0435 \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u0443:<\/p>\n<pre><code class=\"java\"> @Value(\"${kafka.topic.car.reply.partition}\")  private int replyPartition;   ...   @Bean  public KafkaMessageListenerContainer &lt; String, RequestReply &gt; replyListenerContainer() {      ContainerProperties containerProperties = new ContainerProperties(replyTopic);      TopicPartitionInitialOffset initialOffset = new TopicPartitionInitialOffset(replyTopic, replyPartition);      return new KafkaMessageListenerContainer &lt; &gt; (replyConsumerFactory(), containerProperties, initialOffset);  }  private static byte[] intToBytesBigEndian(final int data) {          return new byte[] {              (byte)((data &gt;&gt; 24) &amp; 0xff), (byte)((data &gt;&gt; 16) &amp; 0xff),              (byte)((data &gt;&gt; 8) &amp; 0xff), (byte)((data &gt;&gt; 0) &amp; 0xff),          };      }       ...      record.headers().add(new RecordHeader(KafkaHeaders.REPLY_TOPIC, requestReplyTopic.getBytes()));  record.headers().add(new RecordHeader(KafkaHeaders.REPLY_PARTITION, intToBytesBigEndian(replyPartition)));  RequestReplyFuture &lt; String, RequestReply, RequestReply &gt; sendAndReceive = requestReplyKafkaTemplate.sendAndReceive(record);  ...<\/code><\/pre>\n<p>  \u041d\u0435 \u043e\u0447\u0435\u043d\u044c \u043a\u0440\u0430\u0441\u0438\u0432\u043e, \u043d\u043e \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0422\u0440\u0435\u0431\u0443\u0435\u043c\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u043e\u0431\u0448\u0438\u0440\u043d\u0430 \u0438 API \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0438\u0437\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u043e. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u044f\u0432\u043d\u043e\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0439 \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432. \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043b\u0443\u0447\u0448\u0435.<\/p>\n<h2>\u0418\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0442\u043e\u043f\u0438\u043a\u0430 \u0434\u043b\u044f \u043e\u0442\u0432\u0435\u0442\u0430 \u0438 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0438<\/h2>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u044f\u0446\u0438\u0438 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 <b><a href=\"https:\/\/www.enterpriseintegrationpatterns.com\/patterns\/messaging\/ReturnAddress.html\">Return Address<\/a><\/b>, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u0432\u043c\u0435\u0441\u0442\u0435 \u0442\u043e\u043f\u0438\u043a \u0434\u043b\u044f \u043e\u0442\u0432\u0435\u0442\u0430 \u0438 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u044e. \u0422\u043e\u043f\u0438\u043a \u0434\u043b\u044f \u043e\u0442\u0432\u0435\u0442\u0430 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0437\u0430\u0438\u043d\u0436\u0435\u043a\u0442\u0435\u043d \u0432 <b>RequestReplyTemplate <\/b>\u0438, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 API. \u041a\u043e\u0433\u0434\u0430 \u0440\u0435\u0447\u044c \u0438\u0434\u0435\u0442 \u043e \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u044f\u0445 \u0434\u043b\u044f \u043e\u0442\u0432\u0435\u0442\u0430, \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442: \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043c \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u044e (\u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0438), \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u0443\u044e \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u044e \u0442\u043e\u043f\u0438\u043a\u0430 \u0434\u043b\u044f \u043e\u0442\u0432\u0435\u0442\u0430, \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u044d\u0442\u0443 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u044e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438. \u042d\u0442\u043e \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u043e\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0437\u0430\u0431\u043e\u0442\u0438\u0442\u044c\u0441\u044f \u043e\u0431 \u044d\u0442\u0438\u0445 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430\u0445.<br \/>  \u041f\u0440\u0438 \u044d\u0442\u043e\u043c, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0442\u0430\u043a\u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c API \u0442\u0430\u043a\u0438\u043c, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 <b>KafkaTemplate <\/b>(\u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u0438\u043c \u043c\u0435\u0442\u043e\u0434 <b>sendAndReceive()<\/b> \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0442\u043e\u043f\u0438\u043a):<\/p>\n<pre><code class=\"java\">public class PartitionAwareReplyingKafkaTemplate &lt; K, V, R &gt; extends ReplyingKafkaTemplate &lt; K, V, R &gt; {      public PartitionAwareReplyingKafkaTemplate(ProducerFactory &lt; K, V &gt; producerFactory,         GenericMessageListenerContainer &lt; K, R &gt; replyContainer) {         super(producerFactory, replyContainer);     }      private TopicPartition getFirstAssignedReplyTopicPartition() {         if (getAssignedReplyTopicPartitions() != null &amp;&amp;             getAssignedReplyTopicPartitions().iterator().hasNext()) {             TopicPartition replyPartition = getAssignedReplyTopicPartitions().iterator().next();             if (this.logger.isDebugEnabled()) {                 this.logger.debug(\"Using partition \" + replyPartition.partition());             }             return replyPartition;         } else {             throw new KafkaException(\"Illegal state: No reply partition is assigned to this instance\");         }     }      private static byte[] intToBytesBigEndian(final int data) {         return new byte[] {             (byte)((data &gt;&gt; 24) &amp; 0xff), (byte)((data &gt;&gt; 16) &amp; 0xff),             (byte)((data &gt;&gt; 8) &amp; 0xff), (byte)((data &gt;&gt; 0) &amp; 0xff),         };     }      public RequestReplyFuture &lt; K,     V,     R &gt; sendAndReceiveDefault(@Nullable V data) {         return sendAndReceive(getDefaultTopic(), data);     }      public RequestReplyFuture &lt; K,     V,     R &gt; sendAndReceiveDefault(K key, @Nullable V data) {         return sendAndReceive(getDefaultTopic(), key, data);     }      ...      public RequestReplyFuture &lt; K,     V,     R &gt; sendAndReceive(String topic, @Nullable V data) {         ProducerRecord &lt; K, V &gt; record = new ProducerRecord &lt; &gt; (topic, data);         return doSendAndReceive(record);     }      public RequestReplyFuture &lt; K,     V,     R &gt; sendAndReceive(String topic, K key, @Nullable V data) {         ProducerRecord &lt; K, V &gt; record = new ProducerRecord &lt; &gt; (topic, key, data);         return doSendAndReceive(record);     }      ...      @Override     public RequestReplyFuture &lt; K,     V,     R &gt; sendAndReceive(ProducerRecord &lt; K, V &gt; record) {         return doSendAndReceive(record);     }      protected RequestReplyFuture &lt; K,     V,     R &gt; doSendAndReceive(ProducerRecord &lt; K, V &gt; record) {         TopicPartition replyPartition = getFirstAssignedReplyTopicPartition();         record.headers()             .add(new RecordHeader(KafkaHeaders.REPLY_TOPIC, replyPartition.topic().getBytes()))             .add(new RecordHeader(KafkaHeaders.REPLY_PARTITION,                 intToBytesBigEndian(replyPartition.partition())));         return super.sendAndReceive(record);     } }<\/code><\/pre>\n<p>  \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0448\u0430\u0433: \u0410\u0434\u0430\u043f\u0442\u0438\u0440\u0443\u0435\u043c <b>ListenableFuture <\/b>\u043a \u0431\u043e\u043b\u0435\u0435 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <b>CompletableFuture<\/b>.<\/p>\n<pre><code class=\"java\">public class CompletableFutureReplyingKafkaTemplate &lt; K, V, R &gt; extends PartitionAwareReplyingKafkaTemplate &lt; K, V, R &gt; {      public CompletableFutureReplyingKafkaTemplate(ProducerFactory &lt; K, V &gt; producerFactory,         GenericMessageListenerContainer &lt; K, R &gt; replyContainer) {         super(producerFactory, replyContainer);     }      public CompletableFuture &lt; R &gt; requestReplyDefault(V value) {         return adapt(sendAndReceiveDefault(value));     }      public CompletableFuture &lt; R &gt; requestReplyDefault(K key, V value) {         return adapt(sendAndReceiveDefault(key, value));     }      ...      public CompletableFuture &lt; R &gt; requestReply(String topic, V value) {         return adapt(sendAndReceive(topic, value));     }      public CompletableFuture &lt; R &gt; requestReply(String topic, K key, V value) {         return adapt(sendAndReceive(topic, key, value));     }      ...      private CompletableFuture &lt; R &gt; adapt(RequestReplyFuture &lt; K, V, R &gt; requestReplyFuture) {         CompletableFuture &lt; R &gt; completableResult = new CompletableFuture &lt; R &gt; () {             @Override             public boolean cancel(boolean mayInterruptIfRunning) {                 boolean result = requestReplyFuture.cancel(mayInterruptIfRunning);                 super.cancel(mayInterruptIfRunning);                 return result;             }         };         \/\/ \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043e\u043b\u043b\u0431\u0435\u043a \u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0443 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430         requestReplyFuture.getSendFuture().addCallback(new ListenableFutureCallback &lt; SendResult &lt; K, V &gt;&gt; () {             @Override             public void onSuccess(SendResult &lt; K, V &gt; sendResult) {                 \/\/ NOOP             }             @Override             public void onFailure(Throwable t) {                 completableResult.completeExceptionally(t);             }         });         \/\/ \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043e\u043b\u043b\u0431\u0435\u043a \u043a \u043e\u0442\u0432\u0435\u0442\u0443         requestReplyFuture.addCallback(new ListenableFutureCallback &lt; ConsumerRecord &lt; K, R &gt;&gt; () {             @Override             public void onSuccess(ConsumerRecord &lt; K, R &gt; result) {                 completableResult.complete(result.value());             }             @Override             public void onFailure(Throwable t) {                 completableResult.completeExceptionally(t);             }         });         return completableResult;     } }<\/code><\/pre>\n<p>  \u0423\u043f\u0430\u043a\u0443\u0435\u043c \u044d\u0442\u043e \u0432 \u0443\u0442\u0438\u043b\u0438\u0442\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c API, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0444\u0438\u043b\u043e\u0441\u043e\u0444\u0438\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f Spring <b>\u00ab\u0421\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u0435 \u043d\u0430\u0434 \u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0435\u0439\u00bb (\u00abConvention over Configuration\u00bb)<\/b>. \u0412\u043e\u0442 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043a\u043e\u0434 \u043a\u043b\u0438\u0435\u043d\u0442\u0430:<\/p>\n<pre><code class=\"java\"> @Autowired  private CompletableFutureReplyingKafkaTemplate &lt; String, Request, Reply &gt; requestReplyKafkaTemplate;   ...   requestReplyKafkaTemplate.requestReply(request).thenAccept(reply - &gt;      System.out.println(\"Reply: \" + reply.toString());  );<\/code><\/pre>\n<p>  <\/p>\n<h2>\u041f\u043e\u0434\u0432\u043e\u0434\u0438\u043c \u0438\u0442\u043e\u0433\u0438<\/h2>\n<p>  \u041f\u043e\u0434\u0432\u043e\u0434\u044f \u0438\u0442\u043e\u0433, Spring \u0434\u043b\u044f Kafka 2.2 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 <b>Request-Reply<\/b> \u0432 Apache Kafka, \u043d\u043e API \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0438\u043c\u0435\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0448\u0435\u0440\u043e\u0445\u043e\u0432\u0430\u0442\u043e\u0441\u0442\u0438. \u0412 \u044d\u0442\u043e\u043c \u0432\u044b\u043f\u0443\u0441\u043a\u0435 \u043c\u044b \u0443\u0432\u0438\u0434\u0435\u043b\u0438, \u0447\u0442\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438 \u0438 \u0430\u0434\u0430\u043f\u0442\u0430\u0446\u0438\u0438 API \u043c\u043e\u0433\u0443\u0442 \u0434\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0439 API.<\/p>\n<p>  <b>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 1:<\/b><br \/>  \u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0433\u043b\u0430\u0432\u043d\u044b\u0445 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b, \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0439 \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u043c\u0438, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 (decoupling) \u043f\u0440\u043e\u0434\u044e\u0441\u0435\u0440\u043e\u0432 \u0438 \u043a\u043e\u043d\u0441\u044e\u043c\u0435\u0440\u043e\u0432 \u0441\u043e\u0431\u044b\u0442\u0438\u0439, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u0433\u0438\u0431\u043a\u0438\u0435 \u0438 \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u043e\u043d\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u043a\u0438 \u00ab\u0417\u0430\u043f\u0440\u043e\u0441-\u041e\u0442\u0432\u0435\u0442\u00bb \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u043d\u043e\u0439 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e, \u043a\u043e\u0433\u0434\u0430 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u044e\u0449\u0430\u044f \u0438 \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0430\u044f \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0441\u0438\u043b\u044c\u043d\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439. \u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0435\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<p>  <b>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 2:<\/b> <br \/>  \u0415\u0441\u043b\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f <b>\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0417\u0430\u043f\u0440\u043e\u0441-\u041e\u0442\u0432\u0435\u0442<\/b>, \u0442\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 <b>HTTP <\/b>\u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0449\u0435 \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0435\u0435, \u0447\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <b>\u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u0430\u043d\u0430\u043b\u0430 \u0442\u0438\u043f\u0430 Apache Kafka<\/b>.<br \/>  \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 <b>\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0417\u0430\u043f\u0440\u043e\u0441-\u041e\u0442\u0432\u0435\u0442 \u0447\u0435\u0440\u0435\u0437 Kafka<\/b> \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b. \u0420\u0430\u0437\u0443\u043c\u043d\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0439\u0442\u0435 \u043b\u0443\u0447\u0448\u0438\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b.<\/p>\n<p>  \u041f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 <a href=\"http:\/\/github.com\/callistaenterprise\/blog-synchronous-kafka\">github.com\/callistaenterprise\/blog-synchronous-kafka<\/a>.<\/p>\n<h2>\u041a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438<\/h2>\n<p>  <i>Federico \u2022 7 \u043c\u0435\u0441\u044f\u0446\u0435\u0432 \u043d\u0430\u0437\u0430\u0434<\/i><br \/>  \u0410 \u043a\u043e\u0433\u0434\u0430 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0433\u0438\u0431\u0440\u0438\u0434\u043d\u044b\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0438, \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0432 50% \u043a\u0435\u0439\u0441\u043e\u0432 \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0417\u0430\u043f\u0440\u043e\u0441-\u041e\u0442\u0432\u0435\u0442 \u0438 \u0432 50% \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0439\u043d\u043e\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435? \u041a\u0430\u043a \u043d\u0430\u043c \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c? \u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430\u044f Spring Kafka, \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0443\u0436\u0430\u0441\u043d\u043e.<\/p>\n<p>  <i>Jehanzeb Qayyum \u2022 6 \u043c\u0435\u0441\u044f\u0446\u0435\u0432 \u043d\u0430\u0437\u0430\u0434<\/i><br \/>  \u0422\u0435\u043f\u0435\u0440\u044c Spring \u0438\u043c\u0435\u0435\u0442 \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u0443\u044e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0439 \u0432 \u043e\u0434\u043d\u043e\u043c \u043e\u0431\u0449\u0435\u043c \u0442\u043e\u043f\u0438\u043a\u0435 \u0434\u043b\u044f \u043e\u0442\u0432\u0435\u0442\u0430.<\/p>\n<p>  \u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 2.2, \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0442\u043e\u043f\u0438\u043a \u0434\u043b\u044f \u043e\u0442\u0432\u0435\u0442\u0430 \u0438\u043b\u0438 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u044e \u0438\u0437 \u0441\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u043e\u0442\u0432\u0435\u0442\u0430 (reply container).<\/p>\n<p>  <a href=\"https:\/\/docs.spring.io\/spring-kafka\/reference\/html\/#replying-template\">https:\/\/docs.spring.io\/spring-kafka\/reference\/html\/#replying-template<\/a><\/p>\n<p>  <i>nir rozenberg \u2022 8 \u043c\u0435\u0441\u044f\u0446\u0435\u0432 \u043d\u0430\u0437\u0430\u0434<\/i><br \/>  \u041f\u0440\u0438\u0432\u0435\u0442,<br \/>  \u0412 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c \u0430\u0431\u0437\u0430\u0446\u0435 \u0432\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438, \u0447\u0442\u043e \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0417\u0430\u043f\u0440\u043e\u0441-\u041e\u0442\u0432\u0435\u0442 \u0447\u0435\u0440\u0435\u0437 Kafka \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 HTTP.<br \/>  \u041c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0442\u0430\u043a\u0438\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432?<br \/>  \u0421\u043f\u0430\u0441\u0438\u0431\u043e,<br \/>  Nir<\/p>\n<p>  <i>Janne Keskitalo nir rozenberg \u2022 8 \u043c\u0435\u0441\u044f\u0446\u0435\u0432 \u043d\u0430\u0437\u0430\u0434<\/i><br \/>  \u041c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043c\u0430 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0438 \u0443 \u043c\u0435\u043d\u044f \u0435\u0441\u0442\u044c \u0438\u0434\u0435\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u043c\u0435\u043d \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c\u0438 Kafka \u00ab\u0417\u0430\u043f\u0440\u043e\u0441-\u041e\u0442\u0432\u0435\u0442\u00bb \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u0445\u043e\u0436\u0438\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 (processing affinity). \u0412 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c Kafka \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0441\u0435\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0432 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0445 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443. \u0422\u0430\u043a\u043e\u0439 \u0432\u0438\u0434 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u043b\u0438\u043d\u0435\u0430\u0440\u0438\u0437\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u044c (<a href=\"https:\/\/stackoverflow.com\/a\/19515375\/7430325\">https:\/\/stackoverflow.com\/a\/19515375\/7430325<\/a>), \u043f\u0440\u0438\u0447\u0438\u043d\u043d\u043e-\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0441\u0432\u044f\u0437\u043d\u043e\u0441\u0442\u044c, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435. \u041f\u043e \u0441\u0443\u0442\u0438, \u0443\u0441\u0438\u043b\u0438\u044f \u043f\u043e \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0446\u0438\u0438 \u0431\u044b\u043b\u0438 \u0431\u044b \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0435\u043d\u044b \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 Kafka \u0438 \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0441\u0442\u0440\u043e\u0433\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u0438\u0437\u043e\u043b\u044f\u0446\u0438\u0438 Serializable. <br \/>  \u041c\u043d\u0435 \u0435\u0449\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u043e\u0438\u0442 \u0443\u0433\u043b\u0443\u0431\u0438\u0442\u044c\u0441\u044f \u0432 \u0434\u0435\u0442\u0430\u043b\u0438 \u043d\u0430\u0448\u0435\u0439 \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u043a\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439, \u0447\u0442\u043e\u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0433\u0434\u0435 \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u0434\u043e\u0442\u044f\u0433\u0438\u0432\u0430\u0435\u0442, \u0442\u0430\u043a \u0447\u0442\u043e \u044d\u0442\u043e \u043f\u043e\u043a\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0434\u0435\u044f.<\/p>\n<p>  \u041f\u0435\u0440\u0435\u0432\u0435\u043b <b><a href=\"http:\/\/tele.gg\/middle_java\">@middle_java<\/a><\/b><\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d() } } }t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>      <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\/476156\/\"> https:\/\/habr.com\/ru\/post\/476156\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\"><a href=\"https:\/\/martinfowler.com\/articles\/201701-event-driven.html\">\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b, \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u043c\u0438 (Event Driven Architecture)<\/a>, \u0432 \u0446\u0435\u043b\u043e\u043c, \u0438 <a href=\"https:\/\/kafka.apache.org\/\">Apache Kafka<\/a>, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u043b\u0438 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435. \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0441\u0435\u0445 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b, \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0439 \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u043c\u0438, \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u043e \u0441\u0432\u043e\u0435\u0439 \u0441\u0443\u0442\u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u043c\u043e\u0433\u0443\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0441\u043e\u0431\u044b\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438\/\u043f\u043e\u0442\u043e\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u043a\u0430 <b>\u0421\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u0417\u0430\u043f\u0440\u043e\u0441\u0430-\u041e\u0442\u0432\u0435\u0442\u0430<\/b>. \u0412 \u044d\u0442\u043e\u043c \u0432\u044b\u043f\u0443\u0441\u043a\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e, \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c <b>&#171;<a href=\"https:\/\/www.enterpriseintegrationpatterns.com\/patterns\/messaging\/RequestReply.html\">\u0417\u0430\u043f\u0440\u043e\u0441-\u041e\u0442\u0432\u0435\u0442<\/a>&#171;<\/b> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <b>Apache Kafka<\/b>.<\/p>\n<p>  \u041f\u0435\u0440\u0435\u0432\u0435\u043b <b><a href=\"http:\/\/tele.gg\/middle_java\">@middle_java<\/a><\/b>  <\/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-294780","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/294780","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=294780"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/294780\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=294780"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=294780"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=294780"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}