{"id":453341,"date":"2025-03-26T09:00:11","date_gmt":"2025-03-26T09:00:11","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=453341"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=453341","title":{"rendered":"<span>\u0421\u043e\u0437\u0434\u0430\u0435\u043c Spring Boot Starter \u0434\u043b\u044f Kafka \u0441 Avro: \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e\u0435 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/d7a\/a85\/1fb\/d7aa851fb65bced90a6b1af5178b0977.jpg\" alt=\"Kafka Spring Boot Starter Step By Step\" title=\"Kafka Spring Boot Starter Step By Step\" width=\"1024\" height=\"1024\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d7a\/a85\/1fb\/d7aa851fb65bced90a6b1af5178b0977.jpg\" data-blurred=\"true\"\/><\/p>\n<div><figcaption>Kafka Spring Boot Starter Step By Step<\/figcaption><\/div>\n<\/figure>\n<p>Apache Kafka\u00a0\u2014 \u043c\u043e\u0449\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f\u00a0\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u00a0\u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043d\u043e\u00a0\u0435\u0433\u043e \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f \u0432\u00a0\u043f\u0440\u043e\u0435\u043a\u0442\u044b \u043d\u0430\u00a0Spring Boot \u043c\u043e\u0436\u0435\u0442\u00a0\u0431\u044b\u0442\u044c \u043d\u0435\u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439<\/p>\n<p>\u0412\u00a0\u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0432\u044b \u0443\u0437\u043d\u0430\u0435\u0442\u0435 \u043e\u00a0\u043b\u0443\u0447\u0448\u0438\u0445 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0442\u0430\u0440\u0442\u0435\u0440\u043e\u0432 <strong>Spring Boot Starter \u0434\u043b\u044f\u00a0Kafka \u0441\u00a0\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 Avro<\/strong>, \u0430\u00a0\u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u00a0\u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438. \u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c,\u00a0\u0436\u0435\u043b\u0430\u044e\u0449\u0438\u043c \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441\u00a0Kafka, \u0438 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432, \u0438\u0449\u0443\u0449\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432. \u0414\u043e\u0447\u0438\u0442\u0430\u0432\u0448\u0438\u043c \u0441\u0442\u0430\u0442\u044c\u044e \u0434\u043e\u00a0\u043a\u043e\u043d\u0446\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0439 \u0431\u043e\u043d\u0443\u0441. <\/p>\n<p>\u042f \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043e\u043f\u044b\u0442\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044e Kafka \u0432\u00a0Spring Boot, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0433\u0438\u0431\u043a\u0443\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 Avro.<\/p>\n<ul>\n<li>\n<p><strong>\u0423\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/strong>. \u041c\u043d\u043e\u0433\u0438\u0435 \u0441\u0442\u0430\u0440\u0442\u0435\u0440\u044b \u0434\u043b\u044f\u00a0Kafka \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442, \u043d\u043e\u00a0\u043c\u043e\u0439 \u0444\u043e\u043a\u0443\u0441\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0430\u00a0enterprise\u2011\u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445 (\u0438\u0434\u0435\u043c\u043f\u043e\u0442\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u044c, \u0440\u0435\u0442\u0440\u0430\u0438) \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u0441\u0445\u0435\u043c\u044b Avro \u0447\u0435\u0440\u0435\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u043e\u0447\u0435\u043c\u0443 \u043c\u043d\u0435 \u0432\u0435\u0440\u044f\u0442<\/strong>. \u042f \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0438 \u0438 \u0438\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u0430\u00a0\u0442\u0430\u043a\u0436\u0435 \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u044e \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043a\u043e\u0434.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430<\/strong>. \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 Kafka \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0447\u0430\u0441\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043c\u043d\u043e\u0433\u043e boilerplate-\u043a\u043e\u0434\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>\u0426\u0435\u043b\u044c.<\/strong> \u0414\u0430\u0442\u044c \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044e \u0433\u043e\u0442\u043e\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0438 \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u0438\u0442\u044c \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0430\u0440\u0442\u0435\u0440\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<h2>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Spring Boot Starter?<\/h2>\n<p>Spring Boot Starter \u2014 \u044d\u0442\u043e \u043c\u043e\u0434\u0443\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0433\u043e\u0442\u043e\u0432\u0443\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, spring-boot-starter-web \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440, \u0430 spring-boot-starter-data-jpa \u2014 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u041d\u0430\u0448 \u0441\u0442\u0430\u0440\u0442\u0435\u0440 \u0431\u0443\u0434\u0435\u0442:<\/p>\n<ul>\n<li>\n<p>\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c <code>KafkaProducer<\/code> \u0438 <code>KafkaConsumer<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Avro \u0434\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439;<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0447\u0435\u0440\u0435\u0437 application.yml.<\/p>\n<\/li>\n<\/ul>\n<h2>\u042d\u0442\u0430\u043f\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438<\/h2>\n<p>\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u043a\u043b\u044e\u0447\u0430\u043b \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0430\u0432\u0442\u043e\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0434\u044e\u0441\u0435\u0440\u0430 \u0438 \u043a\u043e\u043d\u0441\u044e\u043c\u0435\u0440\u0430 Kafka. \u0412\u043e\u0442 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0448\u0430\u0433\u0438:<\/p>\n<ol>\n<li>\n<p><strong>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439<\/strong>: <\/p>\n<ul>\n<li>\n<p>Spring Boot \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438;<\/p>\n<\/li>\n<li>\n<p>Spring Kafka \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Kafka;<\/p>\n<\/li>\n<li>\n<p>Apache Avro \u0434\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 (\u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e).<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 KafkaProperties<\/strong>: <\/p>\n<ul>\n<li>\n<p>\u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0438\u0437 application.yml \u0441 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u043c <code>apppetr.kafka<\/code>.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u0410\u0432\u0442\u043e\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f<\/strong>: <\/p>\n<ul>\n<li>\n<p>\u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 <code>KafkaTemplate<\/code> \u0434\u043b\u044f \u043f\u0440\u043e\u0434\u044e\u0441\u0435\u0440\u0430 \u0438 <code>ConcurrentKafkaListenerContainerFactory<\/code> \u0434\u043b\u044f \u043a\u043e\u043d\u0441\u044e\u043c\u0435\u0440\u0430.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 Avro<\/strong>: <\/p>\n<ul>\n<li>\n<p>\u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Avro \u0434\u043b\u044f \u0441\u0442\u0440\u043e\u0433\u043e\u0439 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0441\u0445\u0435\u043c\u0443 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u0441\u0442\u0430\u0440\u0442\u0435\u0440\u0430.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432<\/h3>\n<p>\u0414\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0441\u0442\u0430\u0440\u0442\u0435\u0440\u0430 \u0447\u0435\u0440\u0435\u0437 application.yml \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441 <code>KafkaProperties<\/code> \u0432 kafka-starter\/src\/main\/java\/com\/app\/petr\/KafkaProperties.java:<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">package com.app.petr;  import org.springframework.boot.context.properties.ConfigurationProperties;  import java.util.HashMap; import java.util.Map;  @ConfigurationProperties(prefix = \"apppetr.kafka\") public class KafkaProperties {     private String bootstrapServers = \"localhost:9092\";     private Producer producer = new Producer();     private Consumer consumer = new Consumer();     private String avroSchemaPath;       public static class Producer {         private String topic = \"default-topic\";         private boolean idempotenceEnabled = true; \/\/ \u0418\u0434\u0435\u043c\u043f\u043e\u0442\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0441\u0442\u0438         private int acks = 1; \/\/ \u041f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f: 0, 1, all         private int retries = 3; \/\/ \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043f\u044b\u0442\u043e\u043a \u043f\u0440\u0438 \u0441\u0431\u043e\u044f\u0445         private int retryBackoffMs = 1000; \/\/ \u0417\u0430\u0434\u0435\u0440\u0436\u043a\u0430 \u043c\u0435\u0436\u0434\u0443 \u0440\u0435\u0442\u0440\u0430\u044f\u043c\u0438         private int deliveryTimeoutMs = 120000; \/\/ \u0422\u0430\u0439\u043c\u0430\u0443\u0442 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438         private int requestTimeoutMs = 30000; \/\/ \u0422\u0430\u0439\u043c\u0430\u0443\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430         private int maxInFlightRequests = 5; \/\/ \u041c\u0430\u043a\u0441. \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u0435\u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432         private Map&lt;String, Object&gt; config = new HashMap&lt;&gt;(); \/\/ \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438          public String getTopic() { return topic; }         public void setTopic(String topic) { this.topic = topic; }         public boolean isIdempotenceEnabled() { return idempotenceEnabled; }         public void setIdempotenceEnabled(boolean idempotenceEnabled) { this.idempotenceEnabled = idempotenceEnabled; }         public int getAcks() { return acks; }         public void setAcks(int acks) { this.acks = acks; }         public int getRetries() { return retries; }         public void setRetries(int retries) { this.retries = retries; }         public int getRetryBackoffMs() { return retryBackoffMs; }         public void setRetryBackoffMs(int retryBackoffMs) { this.retryBackoffMs = retryBackoffMs; }         public int getDeliveryTimeoutMs() { return deliveryTimeoutMs; }         public void setDeliveryTimeoutMs(int deliveryTimeoutMs) { this.deliveryTimeoutMs = deliveryTimeoutMs; }         public int getRequestTimeoutMs() { return requestTimeoutMs; }         public void setRequestTimeoutMs(int requestTimeoutMs) { this.requestTimeoutMs = requestTimeoutMs; }         public int getMaxInFlightRequests() { return maxInFlightRequests; }         public void setMaxInFlightRequests(int maxInFlightRequests) { this.maxInFlightRequests = maxInFlightRequests; }         public Map&lt;String, Object&gt; getConfig() { return config; }         public void setConfig(Map&lt;String, Object&gt; config) { this.config = config; }     }      public static class Consumer {         private String topic = \"default-topic\";         private String groupId = \"default-group\";         private int maxPollRecords = 500; \/\/ \u041c\u0430\u043a\u0441. \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0437\u0430 \u043e\u0434\u0438\u043d poll         private int maxPollIntervalMs = 300000; \/\/ \u041c\u0430\u043a\u0441. \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u043c\u0435\u0436\u0434\u0443 poll         private int sessionTimeoutMs = 10000; \/\/ \u0422\u0430\u0439\u043c\u0430\u0443\u0442 \u0441\u0435\u0441\u0441\u0438\u0438         private int heartbeatIntervalMs = 3000; \/\/ \u0418\u043d\u0442\u0435\u0440\u0432\u0430\u043b heartbeat         private int fetchMaxBytes = 52428800; \/\/ \u041c\u0430\u043a\u0441. \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 (50MB)         private boolean autoCommitEnabled = true; \/\/ \u0410\u0432\u0442\u043e\u043a\u043e\u043c\u043c\u0438\u0442 \u043e\u0444\u0444\u0441\u0435\u0442\u043e\u0432         private int autoCommitIntervalMs = 5000; \/\/ \u0418\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0430\u0432\u0442\u043e\u043a\u043e\u043c\u043c\u0438\u0442\u0430         private String autoOffsetReset = \"earliest\"; \/\/ \u0421\u0431\u0440\u043e\u0441 \u043e\u0444\u0444\u0441\u0435\u0442\u0430         private int retryBackoffMs = 1000; \/\/ \u0417\u0430\u0434\u0435\u0440\u0436\u043a\u0430 \u043c\u0435\u0436\u0434\u0443 \u0440\u0435\u0442\u0440\u0430\u044f\u043c\u0438         private int maxRetries = 3; \/\/ \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0435\u0442\u0440\u0430\u0435\u0432         private Map&lt;String, Object&gt; config = new HashMap&lt;&gt;(); \/\/ \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438          public String getTopic() { return topic; }         public void setTopic(String topic) { this.topic = topic; }         public String getGroupId() { return groupId; }         public void setGroupId(String groupId) { this.groupId = groupId; }         public int getMaxPollRecords() { return maxPollRecords; }         public void setMaxPollRecords(int maxPollRecords) { this.maxPollRecords = maxPollRecords; }         public int getMaxPollIntervalMs() { return maxPollIntervalMs; }         public void setMaxPollIntervalMs(int maxPollIntervalMs) { this.maxPollIntervalMs = maxPollIntervalMs; }         public int getSessionTimeoutMs() { return sessionTimeoutMs; }         public void setSessionTimeoutMs(int sessionTimeoutMs) { this.sessionTimeoutMs = sessionTimeoutMs; }         public int getHeartbeatIntervalMs() { return heartbeatIntervalMs; }         public void setHeartbeatIntervalMs(int heartbeatIntervalMs) { this.heartbeatIntervalMs = heartbeatIntervalMs; }         public int getFetchMaxBytes() { return fetchMaxBytes; }         public void setFetchMaxBytes(int fetchMaxBytes) { this.fetchMaxBytes = fetchMaxBytes; }         public boolean isAutoCommitEnabled() { return autoCommitEnabled; }         public void setAutoCommitEnabled(boolean autoCommitEnabled) { this.autoCommitEnabled = autoCommitEnabled; }         public int getAutoCommitIntervalMs() { return autoCommitIntervalMs; }         public void setAutoCommitIntervalMs(int autoCommitIntervalMs) { this.autoCommitIntervalMs = autoCommitIntervalMs; }         public String getAutoOffsetReset() { return autoOffsetReset; }         public void setAutoOffsetReset(String autoOffsetReset) { this.autoOffsetReset = autoOffsetReset; }         public int getRetryBackoffMs() { return retryBackoffMs; }         public void setRetryBackoffMs(int retryBackoffMs) { this.retryBackoffMs = retryBackoffMs; }         public int getMaxRetries() { return maxRetries; }         public void setMaxRetries(int maxRetries) { this.maxRetries = maxRetries; }         public Map&lt;String, Object&gt; getConfig() { return config; }         public void setConfig(Map&lt;String, Object&gt; config) { this.config = config; }     }      public String getBootstrapServers() { return bootstrapServers; }     public void setBootstrapServers(String bootstrapServers) { this.bootstrapServers = bootstrapServers; }     public Producer getProducer() { return producer; }     public void setProducer(Producer producer) { this.producer = producer; }     public Consumer getConsumer() { return consumer; }     public void setConsumer(Consumer consumer) { this.consumer = consumer; }      public String getAvroSchemaPath() {         return avroSchemaPath;     }      public void setAvroSchemaPath(String avroSchemaPath) {         this.avroSchemaPath = avroSchemaPath;     }  }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b Kafka \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"java\">apppetr:   kafka:     bootstrap-servers: localhost:9092     producer:       topic: test-topic       idempotence-enabled: true       acks: all       retries: 5       retry-backoff-ms: 2000       delivery-timeout-ms: 120000       request-timeout-ms: 30000       max-in-flight-requests: 5     consumer:       topic: test-topic       group-id: test-group       max-poll-records: 1000       max-poll-interval-ms: 600000       session-timeout-ms: 15000       heartbeat-interval-ms: 5000       fetch-max-bytes: 52428800       auto-commit-enabled: true       auto-commit-interval-ms: 5000       auto-offset-reset: earliest       retry-backoff-ms: 2000       max-retries: 5     avro-schema-path: ${project.basedir}\/src\/main\/resources\/avro\/message.avdl<\/code><\/pre>\n<h3>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0430\u0432\u0442\u043e\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438<\/h3>\n<p>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441\u0442\u0430\u0440\u0442\u0435\u0440\u0430 \u2014 \u043a\u043b\u0430\u0441\u0441 \u0430\u0432\u0442\u043e\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 <code>KafkaAutoConfiguration<\/code> \u0432 kafka-starter\/src\/main\/java\/com\/app\/petr\/KafkaAutoConfiguration.java:<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">package com.app.petr;  import org.apache.kafka.clients.consumer.ConsumerConfig; import org.apache.kafka.clients.producer.ProducerConfig; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.kafka.annotation.EnableKafka; import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory; import org.springframework.kafka.core.*; import org.springframework.kafka.listener.DefaultErrorHandler; import org.springframework.util.backoff.BackOff; import org.springframework.util.backoff.FixedBackOff;  import java.util.HashMap; import java.util.Map;  @Configuration @ConditionalOnClass({ KafkaTemplate.class, ConcurrentKafkaListenerContainerFactory.class }) @EnableKafka @EnableConfigurationProperties(KafkaProperties.class) @ConditionalOnProperty(prefix = \"apppetr.kafka\", name = \"bootstrap-servers\") public class KafkaAutoConfiguration {      private final KafkaProperties properties;      public KafkaAutoConfiguration(KafkaProperties properties) {         this.properties = properties;     }      \/\/ Producer Configuration     @Bean     @ConditionalOnMissingBean     public ProducerFactory&lt;String, byte[]&gt; producerFactory() {         Map&lt;String, Object&gt; config = new HashMap&lt;&gt;();         config.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, properties.getBootstrapServers());         config.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, \"org.apache.kafka.common.serialization.StringSerializer\");         config.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, \"org.apache.kafka.common.serialization.ByteArraySerializer\");         config.put(ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG, properties.getProducer().isIdempotenceEnabled());         config.put(ProducerConfig.ACKS_CONFIG, String.valueOf(properties.getProducer().getAcks()));         config.put(ProducerConfig.RETRIES_CONFIG, properties.getProducer().getRetries());         config.put(ProducerConfig.RETRY_BACKOFF_MS_CONFIG, properties.getProducer().getRetryBackoffMs());         config.put(ProducerConfig.DELIVERY_TIMEOUT_MS_CONFIG, properties.getProducer().getDeliveryTimeoutMs());         config.put(ProducerConfig.REQUEST_TIMEOUT_MS_CONFIG, properties.getProducer().getRequestTimeoutMs());         config.put(ProducerConfig.MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION, properties.getProducer().getMaxInFlightRequests());         config.putAll(properties.getProducer().getConfig());         return new DefaultKafkaProducerFactory&lt;&gt;(config);     }      @Bean     @ConditionalOnMissingBean     public KafkaTemplate&lt;String, byte[]&gt; kafkaTemplate(ProducerFactory&lt;String, byte[]&gt; producerFactory) {         KafkaTemplate&lt;String, byte[]&gt; template = new KafkaTemplate&lt;&gt;(producerFactory);         template.setDefaultTopic(properties.getProducer().getTopic());         return template;     }      \/\/ Consumer Configuration     @Bean     @ConditionalOnMissingBean     public ConsumerFactory&lt;String, byte[]&gt; consumerFactory() {         Map&lt;String, Object&gt; config = new HashMap&lt;&gt;();         config.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, properties.getBootstrapServers());         config.put(ConsumerConfig.GROUP_ID_CONFIG, properties.getConsumer().getGroupId());         config.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, \"org.apache.kafka.common.serialization.StringDeserializer\");         config.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, \"org.apache.kafka.common.serialization.ByteArrayDeserializer\");         config.put(ConsumerConfig.MAX_POLL_RECORDS_CONFIG, properties.getConsumer().getMaxPollRecords());         config.put(ConsumerConfig.MAX_POLL_INTERVAL_MS_CONFIG, properties.getConsumer().getMaxPollIntervalMs());         config.put(ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG, properties.getConsumer().getSessionTimeoutMs());         config.put(ConsumerConfig.HEARTBEAT_INTERVAL_MS_CONFIG, properties.getConsumer().getHeartbeatIntervalMs());         config.put(ConsumerConfig.FETCH_MAX_BYTES_CONFIG, properties.getConsumer().getFetchMaxBytes());         config.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, properties.getConsumer().isAutoCommitEnabled());         config.put(ConsumerConfig.AUTO_COMMIT_INTERVAL_MS_CONFIG, properties.getConsumer().getAutoCommitIntervalMs());         config.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, properties.getConsumer().getAutoOffsetReset());         config.putAll(properties.getConsumer().getConfig());         return new DefaultKafkaConsumerFactory&lt;&gt;(config);     }      @Bean     @ConditionalOnMissingBean     public ConcurrentKafkaListenerContainerFactory&lt;String, byte[]&gt; kafkaListenerContainerFactory(             ConsumerFactory&lt;String, byte[]&gt; consumerFactory) {         ConcurrentKafkaListenerContainerFactory&lt;String, byte[]&gt; factory =                 new ConcurrentKafkaListenerContainerFactory&lt;&gt;();         factory.setConsumerFactory(consumerFactory);         factory.setConcurrency(1); \/\/ \u041f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c         factory.getContainerProperties().setPollTimeout(3000); \/\/ \u0422\u0430\u0439\u043c\u0430\u0443\u0442 \u043e\u043f\u0440\u043e\u0441\u0430         factory.setCommonErrorHandler(errorHandler()); \/\/ \u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043e\u0448\u0438\u0431\u043e\u043a \u0441 \u0440\u0435\u0442\u0440\u0430\u044f\u043c\u0438         return factory;     }      @Bean     public DefaultErrorHandler errorHandler() {         BackOff backOff = new FixedBackOff(                 properties.getConsumer().getRetryBackoffMs(),                 properties.getConsumer().getMaxRetries()         );         DefaultErrorHandler errorHandler = new DefaultErrorHandler(                 (record, exception) -&gt; {                     System.err.println(\"Failed to process record: \" + record + \", exception: \" + exception.getMessage());                 }, \/\/ \u041b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0448\u0438\u0431\u043e\u043a                 backOff         );         return errorHandler;     } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434:<\/p>\n<ul>\n<li>\n<p>\u0441\u043e\u0437\u0434\u0430\u0451\u0442 <code>KafkaProducer<\/code> \u0438 <code>KafkaConsumer<\/code> \u0441 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438 \u0438\u0437 <code>KafkaProperties<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <code>@ConditionalOnMissingBean<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0433 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0431\u0438\u043d\u044b;<\/p>\n<\/li>\n<li>\n<p>\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 <code>DisposableBean<\/code> \u0434\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0433\u043e \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<h3>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u0438\u043c\u043f\u043e\u0440\u0442\u043e\u0432 \u0430\u0432\u0442\u043e\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438<\/h3>\n<p>\u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0442\u0430\u0440\u0442\u0435\u0440\u0430 \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0444\u0430\u0439\u043b src\/main\/resources\/META-INF\/spring\/org.springframework.boot.autoconfigure.AutoConfiguration.imports, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043c\u0435\u043d\u0438\u043b \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0441 spring.factories \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0430\u0432\u0442\u043e\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0432 Spring Boot 3.x. \u042d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0430\u0432\u0442\u043e\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 Spring Boot \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e:<\/p>\n<pre><code>io.github.bigbox89.KafkaAutoConfiguration<\/code><\/pre>\n<ul>\n<li>\n<p><strong>\u041d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/strong> \u0421\u043e\u043e\u0431\u0449\u0430\u0435\u0442 Spring Boot, \u0447\u0442\u043e <code>KafkaAutoConfiguration<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u0447\u043a\u043e\u0439 \u0432\u0445\u043e\u0434\u0430 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0441\u0442\u0430\u0440\u0442\u0435\u0440\u0430. \u042d\u0442\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f classpath.<\/p>\n<\/li>\n<\/ul>\n<h4>\u0427\u0442\u043e \u0431\u0443\u0434\u0435\u0442, \u0435\u0441\u043b\u0438 \u0435\u0433\u043e \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c<\/h4>\n<p>\u0415\u0441\u043b\u0438 \u0444\u0430\u0439\u043b org.springframework.boot.autoconfigure.AutoConfiguration.imports \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442:<\/p>\n<ul>\n<li>\n<p><strong>\u0410\u0432\u0442\u043e\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u043d\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u0441\u044f<\/strong>. Spring Boot \u043d\u0435 \u043d\u0430\u0439\u0434\u0451\u0442 \u043a\u043b\u0430\u0441\u0441 KafkaAutoConfiguration, \u0438 \u0441\u0442\u0430\u0440\u0442\u0435\u0440 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u0451\u043d, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0432\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e.<\/p>\n<\/li>\n<li>\n<p><strong>\u0422\u0438\u0445\u0438\u0439 \u0441\u0431\u043e\u0439<\/strong>. \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0441\u044f, \u043d\u043e \u043f\u0440\u043e\u0434\u044e\u0441\u0435\u0440 \u0438 \u043a\u043e\u043d\u0441\u044e\u043c\u0435\u0440 Kafka \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u044b, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u043c \u043e\u0448\u0438\u0431\u043a\u0430\u043c (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>@KafkaListener<\/code> \u043d\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442).<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c<\/strong>. \u0412 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 Spring Boot \u0434\u043e 3.0 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c spring.factories, \u043d\u043e \u0432 3.x \u0431\u0435\u0437 AutoConfiguration.imports \u0441\u0442\u0430\u0440\u0442\u0435\u0440 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0435\u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b\u043c.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f<\/h3>\n<h4>\u041f\u0440\u043e\u0434\u044e\u0441\u0435\u0440<\/h4>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440 ProducerApplication \u0432 producer-example\/src\/main\/java\/com\/app\/petr\/ProducerApplication.java<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">package com.app.petr;  import app.petr.Message; import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; import org.springframework.kafka.core.KafkaTemplate;  import java.nio.ByteBuffer;  @SpringBootApplication public class ProducerApplication {      public static void main(String[] args) {         SpringApplication.run(ProducerApplication.class, args);     }      @Bean     public ApplicationRunner runner(KafkaTemplate&lt;String, byte[]&gt; kafkaTemplate, KafkaProperties properties) {         return args -&gt; {             String topic = properties.getProducer().getTopic();             if (topic == null) {                 throw new IllegalStateException(\"Producer topic is not configured\");             }              for (int i = 0; i &lt; 100; i++) {                 Message message = Message.newBuilder()                         .setId(\"id-\" + i)                         .setContent(\"Message \" + i)                         .setTimestamp(System.currentTimeMillis())                         .build();                  ByteBuffer buffer = message.toByteBuffer();                 byte[] messageBytes = new byte[buffer.remaining()];                 buffer.get(messageBytes);                  kafkaTemplate.send(topic, message.getId().toString(), messageBytes);                 System.out.println(\"Sent message: \" + message.getId());                 Thread.sleep(1000);             }         };     } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h4>\u041a\u043e\u043d\u0441\u044e\u043c\u0435\u0440<\/h4>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0438\u043c\u0435\u0440 ConsumerApplication \u0432 consumer-example\/src\/main\/java\/com\/app\/petr\/ConsumerApplication.java<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">package com.app.petr;   import app.petr.Message; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.kafka.annotation.KafkaListener;  import java.nio.ByteBuffer;  @SpringBootApplication public class ConsumerApplication {      public static void main(String[] args) {         SpringApplication.run(ConsumerApplication.class, args);     }      @KafkaListener(topics = \"#{kafkaProperties.consumer.topic}\", groupId = \"#{kafkaProperties.consumer.groupId}\")     public void listen(byte[] message) throws Exception {         Message avroMessage = Message.fromByteBuffer(ByteBuffer.wrap(message));         System.out.printf(\"Received message: id=%s, content=%s, timestamp=%d%n\",                 avroMessage.getId(), avroMessage.getContent(), avroMessage.getTimestamp());     } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h3>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441 Testcontainers<\/h3>\n<p>\u0427\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0441\u0442\u0430\u0440\u0442\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b: <\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">package com.app.petr;  import app.petr.Message; import org.apache.avro.io.Decoder; import org.apache.avro.io.DecoderFactory; import org.apache.avro.io.Encoder; import org.apache.avro.io.EncoderFactory; import org.apache.avro.specific.SpecificDatumReader; import org.apache.avro.specific.SpecificDatumWriter; import org.apache.kafka.clients.consumer.ConsumerConfig; import org.apache.kafka.clients.consumer.ConsumerRecords; import org.apache.kafka.clients.consumer.KafkaConsumer; import org.apache.kafka.clients.producer.KafkaProducer; import org.apache.kafka.clients.producer.ProducerConfig; import org.apache.kafka.clients.producer.ProducerRecord; import org.junit.jupiter.api.Test; import org.testcontainers.containers.KafkaContainer; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.utility.DockerImageName;  import java.io.ByteArrayOutputStream; import java.time.Duration; import java.util.Collections; import java.util.Properties;  import static org.assertj.core.api.Assertions.assertThat;  @Testcontainers public class IntegrationProducerAndConsumerTest {      private static final String TOPIC = \"rest_data\";      @Container     private static final KafkaContainer kafkaContainer = new KafkaContainer(             DockerImageName.parse(\"confluentinc\/cp-kafka:7.3.0\"));      private KafkaProducer&lt;String, byte[]&gt; createProducer() {         Properties props = new Properties();         props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaContainer.getBootstrapServers());         props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, \"org.apache.kafka.common.serialization.StringSerializer\");         props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, \"org.apache.kafka.common.serialization.ByteArraySerializer\");         return new KafkaProducer&lt;&gt;(props);     }      private KafkaConsumer&lt;String, byte[]&gt; createConsumer() {         Properties props = new Properties();         props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaContainer.getBootstrapServers());         props.put(ConsumerConfig.GROUP_ID_CONFIG, \"test-group\");         props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, \"org.apache.kafka.common.serialization.StringDeserializer\");         props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, \"org.apache.kafka.common.serialization.ByteArrayDeserializer\");         props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, \"earliest\");         return new KafkaConsumer&lt;&gt;(props);     }      @Test     public void testProducerAndConsumer() throws Exception {          KafkaProducer&lt;String, byte[]&gt; producer = createProducer();         KafkaConsumer&lt;String, byte[]&gt; consumer = createConsumer();          consumer.subscribe(Collections.singleton(TOPIC));          Message message = Message.newBuilder()                 .setId(\"test-id\")                 .setContent(\"Test content\")                 .setTimestamp(System.currentTimeMillis())                 .build();          ByteArrayOutputStream out = new ByteArrayOutputStream();         Encoder encoder = EncoderFactory.get().binaryEncoder(out, null);         SpecificDatumWriter&lt;Message&gt; writer = new SpecificDatumWriter&lt;&gt;(Message.class);         writer.write(message, encoder);         encoder.flush();         byte[] serializedMessage = out.toByteArray();          ProducerRecord&lt;String, byte[]&gt; record = new ProducerRecord&lt;&gt;(TOPIC, message.getId().toString(), serializedMessage);         producer.send(record).get();         producer.flush();          SpecificDatumReader&lt;Message&gt; reader = new SpecificDatumReader&lt;&gt;(Message.class);         ConsumerRecords&lt;String, byte[]&gt; records = consumer.poll(Duration.ofSeconds(5));         assertThat(records.isEmpty()).isFalse();          records.forEach(consumerRecord -&gt; {             try {                 Decoder decoder = DecoderFactory.get().binaryDecoder(consumerRecord.value(), null);                 Message receivedMessage = reader.read(null, decoder);                 assertThat(receivedMessage.getId().toString()).isEqualTo(message.getId());                 assertThat(receivedMessage.getContent().toString()).isEqualTo(message.getContent());                 assertThat(receivedMessage.getTimestamp()).isEqualTo(message.getTimestamp());             } catch (Exception e) {                 throw new RuntimeException(\"Failed to deserialize message\", e);             }         });          producer.close();         consumer.close();     } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0442\u0435\u0441\u0442\u044b \u0434\u043b\u044f \u043f\u0440\u043e\u0434\u044e\u0441\u0435\u0440\u0430:<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">package com.app.petr;  import app.petr.Message; import org.apache.avro.io.Encoder; import org.apache.avro.io.EncoderFactory; import org.apache.avro.specific.SpecificDatumWriter; import org.apache.kafka.clients.producer.KafkaProducer; import org.apache.kafka.clients.producer.ProducerConfig; import org.apache.kafka.clients.producer.ProducerRecord; import org.apache.kafka.common.errors.TimeoutException; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.testcontainers.containers.KafkaContainer; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.utility.DockerImageName;  import java.io.ByteArrayOutputStream; import java.util.Properties; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future;  import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows;  @Testcontainers public class ProducerApplicationTest {      private static final String TOPIC = \"test_data\";      @Container     private static final KafkaContainer kafkaContainer = new KafkaContainer(             DockerImageName.parse(\"confluentinc\/cp-kafka:7.3.0\"));      @BeforeAll     static void setup() {         kafkaContainer.start();     }      private KafkaProducer&lt;String, byte[]&gt; createProducer(Properties props) {         props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaContainer.getBootstrapServers());         props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, \"org.apache.kafka.common.serialization.StringSerializer\");         props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, \"org.apache.kafka.common.serialization.ByteArraySerializer\");         return new KafkaProducer&lt;&gt;(props);     }      private byte[] serializeMessage(Message message) throws Exception {         ByteArrayOutputStream out = new ByteArrayOutputStream();         Encoder encoder = EncoderFactory.get().binaryEncoder(out, null);         SpecificDatumWriter&lt;Message&gt; writer = new SpecificDatumWriter&lt;&gt;(Message.class);         writer.write(message, encoder);         encoder.flush();         return out.toByteArray();     }      @Test     public void testProducerWithDefaultConfig() throws Exception {         Properties props = new Properties();         KafkaProducer&lt;String, byte[]&gt; producer = createProducer(props);          Message message = Message.newBuilder()                 .setId(\"test-id-1\")                 .setContent(\"Default config test\")                 .setTimestamp(System.currentTimeMillis())                 .build();          byte[] serializedMessage = serializeMessage(message);         ProducerRecord&lt;String, byte[]&gt; record = new ProducerRecord&lt;&gt;(TOPIC, message.getId().toString(), serializedMessage);          Future&lt;?&gt; future = producer.send(record);         producer.flush();          assertThat(future.get()).isNotNull(); \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0443\u0441\u043f\u0435\u0448\u043d\u0443\u044e \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443         producer.close();     }      @Test     public void testProducerWithIdempotenceEnabled() throws Exception {         Properties props = new Properties();         props.put(ProducerConfig.ENABLE_IDEMPOTENCE_CONFIG, \"true\"); \/\/ \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0438\u0434\u0435\u043c\u043f\u043e\u0442\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u044c         props.put(ProducerConfig.ACKS_CONFIG, \"all\"); \/\/ \u0422\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0438\u0434\u0435\u043c\u043f\u043e\u0442\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438         props.put(ProducerConfig.MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION, \"5\"); \/\/ \u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0438\u0434\u0435\u043c\u043f\u043e\u0442\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438         KafkaProducer&lt;String, byte[]&gt; producer = createProducer(props);          Message message = Message.newBuilder()                 .setId(\"test-id-2\")                 .setContent(\"Idempotent test\")                 .setTimestamp(System.currentTimeMillis())                 .build();          byte[] serializedMessage = serializeMessage(message);         ProducerRecord&lt;String, byte[]&gt; record = new ProducerRecord&lt;&gt;(TOPIC, message.getId().toString(), serializedMessage);          Future&lt;?&gt; future = producer.send(record);         producer.send(record); \/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u043e\u0442 \u0436\u0435 \u043a\u043b\u044e\u0447 \u0435\u0449\u0451 \u0440\u0430\u0437         producer.flush();          assertThat(future.get()).isNotNull(); \/\/ \u0423\u0441\u043f\u0435\u0448\u043d\u0430\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0441 \u0438\u0434\u0435\u043c\u043f\u043e\u0442\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u044c\u044e         producer.close();     }      @Test     public void testProducerWithAcksZero() throws Exception {         Properties props = new Properties();         props.put(ProducerConfig.ACKS_CONFIG, \"0\"); \/\/ \u0411\u0435\u0437 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0439         KafkaProducer&lt;String, byte[]&gt; producer = createProducer(props);          Message message = Message.newBuilder()                 .setId(\"test-id-3\")                 .setContent(\"Acks=0 test\")                 .setTimestamp(System.currentTimeMillis())                 .build();          byte[] serializedMessage = serializeMessage(message);         ProducerRecord&lt;String, byte[]&gt; record = new ProducerRecord&lt;&gt;(TOPIC, message.getId().toString(), serializedMessage);          Future&lt;?&gt; future = producer.send(record);         producer.flush();          assertThat(future.get()).isNotNull(); \/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0431\u0435\u0437 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f         producer.close();     }      @Test     public void testProducerWithRetries() throws Exception {         Properties props = new Properties();         props.put(ProducerConfig.RETRIES_CONFIG, \"3\"); \/\/ 3 \u043f\u043e\u043f\u044b\u0442\u043a\u0438         props.put(ProducerConfig.RETRY_BACKOFF_MS_CONFIG, \"100\"); \/\/ \u0417\u0430\u0434\u0435\u0440\u0436\u043a\u0430 \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u043f\u044b\u0442\u043a\u0430\u043c\u0438 100 \u043c\u0441         props.put(ProducerConfig.REQUEST_TIMEOUT_MS_CONFIG, \"500\"); \/\/ \u0423\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u043c \u0442\u0430\u0439\u043c\u0430\u0443\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0434\u043e 500 \u043c\u0441         props.put(ProducerConfig.DELIVERY_TIMEOUT_MS_CONFIG, \"1000\"); \/\/ \u0422\u0430\u0439\u043c\u0430\u0443\u0442 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 1000 \u043c\u0441 (\u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c &gt;= linger.ms + request.timeout.ms)         props.put(ProducerConfig.LINGER_MS_CONFIG, \"0\"); \/\/ \u042f\u0432\u043d\u043e \u0437\u0430\u0434\u0430\u0451\u043c linger.ms \u0434\u043b\u044f \u044f\u0441\u043d\u043e\u0441\u0442\u0438         KafkaProducer&lt;String, byte[]&gt; producer = createProducer(props);          Message message = Message.newBuilder()                 .setId(\"test-id-4\")                 .setContent(\"Retries test\")                 .setTimestamp(System.currentTimeMillis())                 .build();          byte[] serializedMessage = serializeMessage(message);         ProducerRecord&lt;String, byte[]&gt; record = new ProducerRecord&lt;&gt;(TOPIC, message.getId().toString(), serializedMessage);          Future&lt;?&gt; future = producer.send(record);         producer.flush();          assertThat(future.get()).isNotNull(); \/\/ \u0423\u0441\u043f\u0435\u0448\u043d\u0430\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0441 \u0440\u0435\u0442\u0440\u0430\u044f\u043c\u0438         producer.close();     }      @Test     public void testProducerWithShortTimeout() {         Properties props = new Properties();         props.put(ProducerConfig.REQUEST_TIMEOUT_MS_CONFIG, \"1\"); \/\/ \u041e\u0447\u0435\u043d\u044c \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 \u0442\u0430\u0439\u043c\u0430\u0443\u0442         props.put(ProducerConfig.DELIVERY_TIMEOUT_MS_CONFIG, \"1\"); \/\/ \u041e\u0447\u0435\u043d\u044c \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 \u0442\u0430\u0439\u043c\u0430\u0443\u0442 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438         KafkaProducer&lt;String, byte[]&gt; producer = createProducer(props);          Message message = Message.newBuilder()                 .setId(\"test-id-5\")                 .setContent(\"Short timeout test\")                 .setTimestamp(System.currentTimeMillis())                 .build();          byte[] serializedMessage;         try {             serializedMessage = serializeMessage(message);         } catch (Exception e) {             throw new RuntimeException(\"Serialization failed\", e);         }         ProducerRecord&lt;String, byte[]&gt; record = new ProducerRecord&lt;&gt;(TOPIC, message.getId().toString(), serializedMessage);          Future&lt;?&gt; future = producer.send(record);          \/\/ \u041e\u0436\u0438\u0434\u0430\u0435\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438\u0437-\u0437\u0430 \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0433\u043e \u0442\u0430\u0439\u043c\u0430\u0443\u0442\u0430         assertThrows(ExecutionException.class, future::get, \"Expected timeout exception due to short timeout\");         assertThat(future.isDone()).isTrue();          producer.close();     } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0418 \u043a\u043e\u043dc\u044e\u043c\u0435\u0440\u0430:<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">package com.app.petr;  import app.petr.Message; import org.apache.avro.io.Decoder; import org.apache.avro.io.DecoderFactory; import org.apache.avro.io.Encoder; import org.apache.avro.io.EncoderFactory; import org.apache.avro.specific.SpecificDatumReader; import org.apache.avro.specific.SpecificDatumWriter; import org.apache.kafka.clients.admin.AdminClient; import org.apache.kafka.clients.admin.NewTopic; import org.apache.kafka.clients.consumer.ConsumerConfig; import org.apache.kafka.clients.consumer.ConsumerRecords; import org.apache.kafka.clients.consumer.KafkaConsumer; import org.apache.kafka.clients.producer.KafkaProducer; import org.apache.kafka.clients.producer.ProducerConfig; import org.apache.kafka.clients.producer.ProducerRecord; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.testcontainers.containers.KafkaContainer; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.utility.DockerImageName;  import java.io.ByteArrayOutputStream; import java.time.Duration; import java.util.Collections; import java.util.Properties;  import static org.assertj.core.api.Assertions.assertThat;  @Testcontainers public class ConsumerApplicationTest {      private static final String TOPIC = \"consumer_test_data\";      @Container     private static final KafkaContainer kafkaContainer = new KafkaContainer(             DockerImageName.parse(\"confluentinc\/cp-kafka:7.3.0\"));      @BeforeAll     static void setup() {         kafkaContainer.start();     }      @BeforeEach     void clearTopic() {         Properties adminProps = new Properties();         adminProps.put(\"bootstrap.servers\", kafkaContainer.getBootstrapServers());         try (AdminClient adminClient = AdminClient.create(adminProps)) {             adminClient.deleteTopics(Collections.singleton(TOPIC)).all().get();             adminClient.createTopics(Collections.singleton(new NewTopic(TOPIC, 1, (short) 1))).all().get();         } catch (Exception e) {             \/\/ \u0418\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0438, \u0435\u0441\u043b\u0438 \u0442\u043e\u043f\u0438\u043a \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043b         }     }      private KafkaProducer&lt;String, byte[]&gt; createProducer() {         Properties props = new Properties();         props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaContainer.getBootstrapServers());         props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, \"org.apache.kafka.common.serialization.StringSerializer\");         props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, \"org.apache.kafka.common.serialization.ByteArraySerializer\");         return new KafkaProducer&lt;&gt;(props);     }      private KafkaConsumer&lt;String, byte[]&gt; createConsumer(Properties props) {         props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaContainer.getBootstrapServers());         props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, \"org.apache.kafka.common.serialization.StringDeserializer\");         props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, \"org.apache.kafka.common.serialization.ByteArrayDeserializer\");         return new KafkaConsumer&lt;&gt;(props);     }      private byte[] serializeMessage(Message message) throws Exception {         ByteArrayOutputStream out = new ByteArrayOutputStream();         Encoder encoder = EncoderFactory.get().binaryEncoder(out, null);         SpecificDatumWriter&lt;Message&gt; writer = new SpecificDatumWriter&lt;&gt;(Message.class);         writer.write(message, encoder);         encoder.flush();         return out.toByteArray();     }      private Message deserializeMessage(byte[] data) throws Exception {         Decoder decoder = DecoderFactory.get().binaryDecoder(data, null);         SpecificDatumReader&lt;Message&gt; reader = new SpecificDatumReader&lt;&gt;(Message.class);         return reader.read(null, decoder);     }      private void sendMessages(int count) throws Exception {         KafkaProducer&lt;String, byte[]&gt; producer = createProducer();         for (int i = 0; i &lt; count; i++) {             Message message = Message.newBuilder()                     .setId(\"id-\" + i)                     .setContent(\"Message \" + i)                     .setTimestamp(System.currentTimeMillis())                     .build();             byte[] serializedMessage = serializeMessage(message);             producer.send(new ProducerRecord&lt;&gt;(TOPIC, message.getId().toString(), serializedMessage)).get();         }         producer.flush();         producer.close();     }      @Test     public void testConsumerWithDefaultConfig() throws Exception {         Properties props = new Properties();         props.put(ConsumerConfig.GROUP_ID_CONFIG, \"default-group-\" + System.nanoTime());         props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, \"earliest\");         KafkaConsumer&lt;String, byte[]&gt; consumer = createConsumer(props);          consumer.subscribe(Collections.singleton(TOPIC));         sendMessages(5);          ConsumerRecords&lt;String, byte[]&gt; records = consumer.poll(Duration.ofSeconds(5));         assertThat(records.count()).isEqualTo(5);          consumer.close();     }      @Test     public void testConsumerWithMaxPollRecords() throws Exception {         Properties props = new Properties();         props.put(ConsumerConfig.GROUP_ID_CONFIG, \"max-poll-group-\" + System.nanoTime());         props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, \"earliest\");         props.put(ConsumerConfig.MAX_POLL_RECORDS_CONFIG, \"2\");         KafkaConsumer&lt;String, byte[]&gt; consumer = createConsumer(props);          consumer.subscribe(Collections.singleton(TOPIC));         sendMessages(5);          ConsumerRecords&lt;String, byte[]&gt; records = consumer.poll(Duration.ofSeconds(5));         assertThat(records.count()).isLessThanOrEqualTo(2);          consumer.close();     }      @Test     public void testConsumerWithAutoOffsetResetLatest() throws Exception {         Properties props = new Properties();         props.put(ConsumerConfig.GROUP_ID_CONFIG, \"latest-group-\" + System.nanoTime());         props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, \"latest\");         KafkaConsumer&lt;String, byte[]&gt; consumer = createConsumer(props);          \/\/ \u041f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c\u0441\u044f \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c poll \u0434\u043b\u044f \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438         consumer.subscribe(Collections.singleton(TOPIC));         consumer.poll(Duration.ofSeconds(20)); \/\/ \u0414\u0430\u0451\u043c Kafka \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0441\u044e\u043c\u0435\u0440\u0430          \/\/ \u0423\u0431\u0435\u0436\u0434\u0430\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u0434\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f         ConsumerRecords&lt;String, byte[]&gt; recordsBefore = consumer.poll(Duration.ofSeconds(1));         assertThat(recordsBefore.isEmpty()).isTrue();          \/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c 3 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u043d\u043e\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438         sendMessages(3);          \/\/ \u0427\u0438\u0442\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f         ConsumerRecords&lt;String, byte[]&gt; recordsAfter = consumer.poll(Duration.ofSeconds(5));         assertThat(recordsAfter.count()).isEqualTo(3);          consumer.close();     }      @Test     public void testConsumerWithDisableAutoCommit() throws Exception {         Properties props = new Properties();         props.put(ConsumerConfig.GROUP_ID_CONFIG, \"no-auto-commit-group-\" + System.nanoTime());         props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, \"earliest\");         props.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, \"false\");         KafkaConsumer&lt;String, byte[]&gt; consumer = createConsumer(props);          consumer.subscribe(Collections.singleton(TOPIC));         sendMessages(5);          ConsumerRecords&lt;String, byte[]&gt; records = consumer.poll(Duration.ofSeconds(5));         assertThat(records.count()).isEqualTo(5);          consumer.close();         consumer = createConsumer(props);         consumer.subscribe(Collections.singleton(TOPIC));         ConsumerRecords&lt;String, byte[]&gt; recordsAgain = consumer.poll(Duration.ofSeconds(5));         assertThat(recordsAgain.count()).isEqualTo(5);          consumer.close();     }      @Test     public void testConsumerWithShortSessionTimeout() throws Exception {         Properties props = new Properties();         props.put(ConsumerConfig.GROUP_ID_CONFIG, \"short-session-group-\" + System.nanoTime());         props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, \"earliest\");         props.put(ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG, \"6000\");         props.put(ConsumerConfig.HEARTBEAT_INTERVAL_MS_CONFIG, \"2000\");         KafkaConsumer&lt;String, byte[]&gt; consumer = createConsumer(props);          consumer.subscribe(Collections.singleton(TOPIC));         sendMessages(3);          ConsumerRecords&lt;String, byte[]&gt; records = consumer.poll(Duration.ofSeconds(5));         assertThat(records.count()).isEqualTo(3);          consumer.close();     } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u0435\u0441\u0442:<\/p>\n<ul>\n<li>\n<p>Testcontainers \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 Kafka-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440;<\/p>\n<\/li>\n<li>\n<p>\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u0434\u044e\u0441\u0435\u0440 \u0438 \u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0441\u044e\u043c\u0435\u0440\u043e\u043c;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u0441\u0442\u0430\u0440\u0442\u0435\u0440\u0430<\/h3>\n<ul>\n<li>\n<p><strong>\u041f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f<\/strong>. \u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c application.yml.<\/p>\n<\/li>\n<li>\n<p><strong>\u0413\u0438\u0431\u043a\u043e\u0441\u0442\u044c<\/strong>. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0431\u0438\u043d\u044b \u0438\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>\u0422\u0438\u043f\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c<\/strong>. Avro \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0441\u0442\u0440\u043e\u0433\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<\/ul>\n<h2>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0438 \u0438\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0435<\/h2>\n<h3>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 1: \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f Avro-\u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435\u0440\u0430<\/h3>\n<p><strong>\u0421\u0438\u0442\u0443\u0430\u0446\u0438\u044f<\/strong>: \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b avro-maven-plugin \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438\u0437 message.avdl \u0432 \u0441\u0442\u0430\u0440\u0442\u0435\u0440\u0435. \u042d\u0442\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u043b\u043e \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u044c, \u0442\u0430\u043a \u043a\u0430\u043a \u0441\u0445\u0435\u043c\u0430 \u0431\u044b\u043b\u0430 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439.<\/p>\n<p><strong>\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/strong>:<\/p>\n<ul>\n<li>\n<p>\u0443\u0431\u0440\u0430\u043b \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u0438\u0437 \u0441\u0442\u0430\u0440\u0442\u0435\u0440\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0434\u043e\u0431\u0430\u0432\u0438\u043b \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 avro-schema-path \u0432 KafkaProperties, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u043f\u0443\u0442\u044c \u043a \u0441\u0445\u0435\u043c\u0435;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0435\u0440\u0435\u043b\u043e\u0436\u0438\u043b \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0437\u0430 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438<\/strong>:<\/p>\n<pre><code class=\"java\">apppetr:   kafka:     avro-schema-path: ${project.basedir}\/src\/main\/resources\/avro\/message.avdl<\/code><\/pre>\n<h3>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 2: \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u0442\u0435\u0441\u0442\u0430\u0445 \u0441 auto.offset.reset=latest<\/h3>\n<p><strong>\u0421\u0438\u0442\u0443\u0430\u0446\u0438\u044f<\/strong>: \u0442\u0435\u0441\u0442 <code>testConsumerWithAutoOffsetResetLatest<\/code> \u043e\u0436\u0438\u0434\u0430\u043b 3 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u043b 1 \u0438\u0437-\u0437\u0430 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438.<\/p>\n<p><strong>\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/strong>:<\/p>\n<ul>\n<li>\n<p>\u0434\u043e\u0431\u0430\u0432\u0438\u043b <code>consumer.poll(Duration.ofSeconds(2))<\/code> \u043f\u043e\u0441\u043b\u0435 <code>subscribe<\/code>, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0436\u0434\u0430\u0442\u044c\u0441\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u043d\u0441\u044e\u043c\u0435\u0440\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0443\u0431\u0440\u0430\u043b <code>Thread.sleep<\/code>, \u0441\u0434\u0435\u043b\u0430\u0432 \u0442\u0435\u0441\u0442 \u0431\u043e\u043b\u0435\u0435 \u043d\u0430\u0434\u0451\u0436\u043d\u044b\u043c.<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"java\">consumer.subscribe(Collections.singleton(TOPIC)); consumer.poll(Duration.ofSeconds(20)); sendMessages(3); assertThat(consumer.poll(Duration.ofSeconds(5)).count()).isEqualTo(3);<\/code><\/pre>\n<h2>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0440\u0442\u0435\u0440\u0430<\/h2>\n<h3>1. \u041d\u0430\u0434\u0451\u0436\u043d\u0430\u044f \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0430 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439<\/h3>\n<p><strong>\u0417\u0430\u0434\u0430\u0447\u0430<\/strong>: \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0443 \u0431\u0435\u0437 \u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0442\u043e\u0432.<\/p>\n<p><strong>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f<\/strong>:<\/p>\n<pre><code class=\"java\">apppetr:   kafka:     bootstrap-servers: kafka1:9092,kafka2:9092     producer:       topic: transactions       idempotence-enabled: true       acks: all       retries: 5       retry-backoff-ms: 2000     avro-schema-path: src\/main\/resources\/avro\/transaction.avdl<\/code><\/pre>\n<p><strong>\u041a\u043e\u0434<\/strong>:<\/p>\n<pre><code class=\"java\">@Autowired private KafkaTemplate&lt;String, byte[]&gt; kafkaTemplate;  public void sendTransaction(Transaction tx) throws Exception {     ByteArrayOutputStream out = new ByteArrayOutputStream();     Encoder encoder = EncoderFactory.get().binaryEncoder(out, null);     SpecificDatumWriter&lt;Transaction&gt; writer = new SpecificDatumWriter&lt;&gt;(Transaction.class);     writer.write(tx, encoder);     encoder.flush();     kafkaTemplate.send(\"transactions\", tx.getId().toString(), out.toByteArray()); }<\/code><\/pre>\n<h3>2. \u0412\u044b\u0441\u043e\u043a\u043e\u0441\u043a\u043e\u0440\u043e\u0441\u0442\u043d\u043e\u0439 \u0441\u0431\u043e\u0440 \u043b\u043e\u0433\u043e\u0432<\/h3>\n<p><strong>\u0417\u0430\u0434\u0430\u0447\u0430<\/strong>: \u0431\u044b\u0441\u0442\u0440\u0430\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u043b\u043e\u0433\u043e\u0432 \u0441 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e\u0439 \u043f\u043e\u0442\u0435\u0440\u0435\u0439.<\/p>\n<p><strong>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f<\/strong>:<\/p>\n<pre><code class=\"java\">apppetr:   kafka:     bootstrap-servers: localhost:9092     producer:       topic: logs       acks: 0       max-in-flight-requests: 10     consumer:       topic: logs       group-id: log-collector       max-poll-records: 1000       auto-offset-reset: latest     avro-schema-path: src\/main\/resources\/avro\/log.avdl<\/code><\/pre>\n<p><strong>\u041a\u043e\u0434<\/strong>:<\/p>\n<pre><code class=\"java\">@KafkaListener(topics = \"logs\", groupId = \"log-collector\") public void processLog(byte[] data) throws Exception {     Decoder decoder = DecoderFactory.get().binaryDecoder(data, null);     SpecificDatumReader&lt;Log&gt; reader = new SpecificDatumReader&lt;&gt;(Log.class);     Log log = reader.read(null, decoder);     System.out.println(\"Log: \" + log.getMessage()); }<\/code><\/pre>\n<h3>3. \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0441 \u0440\u0435\u0442\u0440\u0430\u044f\u043c\u0438<\/h3>\n<p><strong>\u0417\u0430\u0434\u0430\u0447\u0430<\/strong>: \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043f\u0440\u0438 \u0441\u0431\u043e\u044f\u0445.<\/p>\n<p><strong>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f<\/strong>:<\/p>\n<pre><code class=\"java\">apppetr:   kafka:     bootstrap-servers: kafka:9092     consumer:       topic: events       group-id: event-processor       retry-backoff-ms: 2000       max-retries: 5     avro-schema-path: src\/main\/resources\/avro\/event.avdl<\/code><\/pre>\n<p><strong>\u041a\u043e\u0434<\/strong>:<\/p>\n<pre><code class=\"java\">@KafkaListener(topics = \"events\", groupId = \"event-processor\") public void handleEvent(byte[] data) throws Exception {     Decoder decoder = DecoderFactory.get().binaryDecoder(data, null);     SpecificDatumReader&lt;Event&gt; reader = new SpecificDatumReader&lt;&gt;(Event.class);     Event event = reader.read(null, decoder);     processEvent(event); \/\/ \u041b\u043e\u0433\u0438\u043a\u0430 \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f\u043c\u0438 }<\/code><\/pre>\n<h2>\u0411\u043e\u043d\u0443\u0441 \u0434\u043e\u0447\u0438\u0442\u0430\u0432\u0448\u0438\u043c<\/h2>\n<p>\u041f\u0430\u043c\u044f\u0442\u043a\u0430-\u0448\u043f\u0430\u0440\u0433\u0430\u043b\u043a\u0430 \u043f\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 Kafka.<\/p>\n<h3>\u041e\u0431\u0449\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b<\/h3>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440<\/p>\n<\/th>\n<th data-colwidth=\"253\" width=\"253\">\n<p align=\"left\">\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0422\u0438\u043f<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">bootstrap.servers<\/p>\n<\/td>\n<td data-colwidth=\"253\" width=\"253\">\n<p align=\"left\">\u0421\u043f\u0438\u0441\u043e\u043a \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u0431\u0440\u043e\u043a\u0435\u0440\u043e\u0432 Kafka<\/p>\n<\/td>\n<td>\n<p align=\"left\">String<\/p>\n<\/td>\n<td>\n<p align=\"left\">localhost:9092<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h3>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u0440\u043e\u0434\u044e\u0441\u0435\u0440\u0430<\/h3>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440<\/p>\n<\/th>\n<th data-colwidth=\"256\" width=\"256\">\n<p align=\"left\">\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0422\u0438\u043f<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">key.serializer<\/p>\n<\/td>\n<td data-colwidth=\"256\" width=\"256\">\n<p align=\"left\">\u0421\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043a\u043b\u044e\u0447\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">Class<\/p>\n<\/td>\n<td>\n<p align=\"left\">&#8212;<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">value.serializer<\/p>\n<\/td>\n<td data-colwidth=\"256\" width=\"256\">\n<p align=\"left\">\u0421\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/p>\n<\/td>\n<td>\n<p align=\"left\">Class<\/p>\n<\/td>\n<td>\n<p align=\"left\">&#8212;<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">acks<\/p>\n<\/td>\n<td data-colwidth=\"256\" width=\"256\">\n<p align=\"left\">\u0423\u0440\u043e\u0432\u0435\u043d\u044c \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0439 (0, 1, all)<\/p>\n<\/td>\n<td>\n<p align=\"left\">String<\/p>\n<\/td>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">retries<\/p>\n<\/td>\n<td data-colwidth=\"256\" width=\"256\">\n<p align=\"left\">\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0435\u0442\u0440\u0430\u0435\u0432 \u043f\u0440\u0438 \u0441\u0431\u043e\u044f\u0445<\/p>\n<\/td>\n<td>\n<p align=\"left\">int<\/p>\n<\/td>\n<td>\n<p align=\"left\">0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><a href=\"http:\/\/retry.backoff.ms\">retry.backoff.ms<\/a><\/p>\n<\/td>\n<td data-colwidth=\"256\" width=\"256\">\n<p align=\"left\">\u0417\u0430\u0434\u0435\u0440\u0436\u043a\u0430 \u043c\u0435\u0436\u0434\u0443 \u0440\u0435\u0442\u0440\u0430\u044f\u043c\u0438 (\u043c\u0441)<\/p>\n<\/td>\n<td>\n<p align=\"left\">int<\/p>\n<\/td>\n<td>\n<p align=\"left\">100<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">enable.idempotence<\/p>\n<\/td>\n<td data-colwidth=\"256\" width=\"256\">\n<p align=\"left\">\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438\u0434\u0435\u043c\u043f\u043e\u0442\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438<\/p>\n<\/td>\n<td>\n<p align=\"left\">boolean<\/p>\n<\/td>\n<td>\n<p align=\"left\">false<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><a href=\"http:\/\/max.in\">max.in<\/a>.flight.requests.per.connection<\/p>\n<\/td>\n<td data-colwidth=\"256\" width=\"256\">\n<p align=\"left\">\u041c\u0430\u043a\u0441. \u043d\u0435\u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0451\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/p>\n<\/td>\n<td>\n<p align=\"left\">int<\/p>\n<\/td>\n<td>\n<p align=\"left\">5<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><a href=\"http:\/\/delivery.timeout.ms\">delivery.timeout.ms<\/a><\/p>\n<\/td>\n<td data-colwidth=\"256\" width=\"256\">\n<p align=\"left\">\u041e\u0431\u0449\u0438\u0439 \u0442\u0430\u0439\u043c\u0430\u0443\u0442 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 (\u043c\u0441)<\/p>\n<\/td>\n<td>\n<p align=\"left\">int<\/p>\n<\/td>\n<td>\n<p align=\"left\">120000 (2 \u043c\u0438\u043d)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><a href=\"http:\/\/request.timeout.ms\">request.timeout.ms<\/a><\/p>\n<\/td>\n<td data-colwidth=\"256\" width=\"256\">\n<p align=\"left\">\u0422\u0430\u0439\u043c\u0430\u0443\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043a \u0431\u0440\u043e\u043a\u0435\u0440\u0443 (\u043c\u0441)<\/p>\n<\/td>\n<td>\n<p align=\"left\">int<\/p>\n<\/td>\n<td>\n<p align=\"left\">30000 (30 \u0441\u0435\u043a)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">buffer.memory<\/p>\n<\/td>\n<td data-colwidth=\"256\" width=\"256\">\n<p align=\"left\">\u0420\u0430\u0437\u043c\u0435\u0440 \u0431\u0443\u0444\u0435\u0440\u0430 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 (\u0431\u0430\u0439\u0442)<\/p>\n<\/td>\n<td>\n<p align=\"left\">long<\/p>\n<\/td>\n<td>\n<p align=\"left\">33554432 (32MB)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">batch.size<\/p>\n<\/td>\n<td data-colwidth=\"256\" width=\"256\">\n<p align=\"left\">\u0420\u0430\u0437\u043c\u0435\u0440 \u0431\u0430\u0442\u0447\u0430 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 (\u0431\u0430\u0439\u0442)<\/p>\n<\/td>\n<td>\n<p align=\"left\">int<\/p>\n<\/td>\n<td>\n<p align=\"left\">16384 (16KB)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><a href=\"http:\/\/linger.ms\">linger.ms<\/a><\/p>\n<\/td>\n<td data-colwidth=\"256\" width=\"256\">\n<p align=\"left\">\u0417\u0430\u0434\u0435\u0440\u0436\u043a\u0430 \u043f\u0435\u0440\u0435\u0434 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u043e\u0439 \u0431\u0430\u0442\u0447\u0430 (\u043c\u0441)<\/p>\n<\/td>\n<td>\n<p align=\"left\">int<\/p>\n<\/td>\n<td>\n<p align=\"left\">0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">compression.type<\/p>\n<\/td>\n<td data-colwidth=\"256\" width=\"256\">\n<p align=\"left\">\u0422\u0438\u043f \u0441\u0436\u0430\u0442\u0438\u044f (none, gzip, snappy, lz4, zstd)<\/p>\n<\/td>\n<td>\n<p align=\"left\">String<\/p>\n<\/td>\n<td>\n<p align=\"left\">none<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h3>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043a\u043e\u043d\u0441\u044e\u043c\u0435\u0440\u0430<\/h3>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440<\/p>\n<\/th>\n<th data-colwidth=\"257\" width=\"257\">\n<p align=\"left\">\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0422\u0438\u043f<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">key.deserializer<\/p>\n<\/td>\n<td data-colwidth=\"257\" width=\"257\">\n<p align=\"left\">\u0414\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043a\u043b\u044e\u0447\u0430<\/p>\n<\/td>\n<td>\n<p align=\"left\">Class<\/p>\n<\/td>\n<td>\n<p align=\"left\">&#8212;<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">value.deserializer<\/p>\n<\/td>\n<td data-colwidth=\"257\" width=\"257\">\n<p align=\"left\">\u0414\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/p>\n<\/td>\n<td>\n<p align=\"left\">Class<\/p>\n<\/td>\n<td>\n<p align=\"left\">&#8212;<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><a href=\"http:\/\/group.id\">group.id<\/a><\/p>\n<\/td>\n<td data-colwidth=\"257\" width=\"257\">\n<p align=\"left\">\u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0433\u0440\u0443\u043f\u043f\u044b \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0435\u0439<\/p>\n<\/td>\n<td>\n<p align=\"left\">String<\/p>\n<\/td>\n<td>\n<p align=\"left\">null<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">auto.offset.reset<\/p>\n<\/td>\n<td data-colwidth=\"257\" width=\"257\">\n<p align=\"left\">\u041f\u043e\u043b\u0438\u0442\u0438\u043a\u0430 \u0441\u0431\u0440\u043e\u0441\u0430 \u043e\u0444\u0444\u0441\u0435\u0442\u0430 (earliest, latest, none)<\/p>\n<\/td>\n<td>\n<p align=\"left\">String<\/p>\n<\/td>\n<td>\n<p align=\"left\">latest<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><a href=\"http:\/\/enable.auto\">enable.auto<\/a>.commit<\/p>\n<\/td>\n<td data-colwidth=\"257\" width=\"257\">\n<p align=\"left\">\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0430\u0432\u0442\u043e\u043a\u043e\u043c\u043c\u0438\u0442\u0430 \u043e\u0444\u0444\u0441\u0435\u0442\u043e\u0432<\/p>\n<\/td>\n<td>\n<p align=\"left\">boolean<\/p>\n<\/td>\n<td>\n<p align=\"left\">true<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><a href=\"http:\/\/auto.commit.interval.ms\">auto.commit.interval.ms<\/a><\/p>\n<\/td>\n<td data-colwidth=\"257\" width=\"257\">\n<p align=\"left\">\u0418\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0430\u0432\u0442\u043e\u043a\u043e\u043c\u043c\u0438\u0442\u0430 (\u043c\u0441)<\/p>\n<\/td>\n<td>\n<p align=\"left\">int<\/p>\n<\/td>\n<td>\n<p align=\"left\">5000 (5 \u0441\u0435\u043a)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">max.poll.records<\/p>\n<\/td>\n<td data-colwidth=\"257\" width=\"257\">\n<p align=\"left\">\u041c\u0430\u043a\u0441. \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0437\u0430 \u043e\u0434\u0438\u043d poll<\/p>\n<\/td>\n<td>\n<p align=\"left\">int<\/p>\n<\/td>\n<td>\n<p align=\"left\">500<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><a href=\"http:\/\/max.poll.interval.ms\">max.poll.interval.ms<\/a><\/p>\n<\/td>\n<td data-colwidth=\"257\" width=\"257\">\n<p align=\"left\">\u041c\u0430\u043a\u0441. \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u043c\u0435\u0436\u0434\u0443 poll (\u043c\u0441)<\/p>\n<\/td>\n<td>\n<p align=\"left\">int<\/p>\n<\/td>\n<td>\n<p align=\"left\">300000 (5 \u043c\u0438\u043d)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><a href=\"http:\/\/session.timeout.ms\">session.timeout.ms<\/a><\/p>\n<\/td>\n<td data-colwidth=\"257\" width=\"257\">\n<p align=\"left\">\u0422\u0430\u0439\u043c\u0430\u0443\u0442 \u0441\u0435\u0441\u0441\u0438\u0438 \u0433\u0440\u0443\u043f\u043f\u044b (\u043c\u0441)<\/p>\n<\/td>\n<td>\n<p align=\"left\">int<\/p>\n<\/td>\n<td>\n<p align=\"left\">10000 (10 \u0441\u0435\u043a)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><a href=\"http:\/\/heartbeat.interval.ms\">heartbeat.interval.ms<\/a><\/p>\n<\/td>\n<td data-colwidth=\"257\" width=\"257\">\n<p align=\"left\">\u0418\u043d\u0442\u0435\u0440\u0432\u0430\u043b heartbeat (\u043c\u0441)<\/p>\n<\/td>\n<td>\n<p align=\"left\">int<\/p>\n<\/td>\n<td>\n<p align=\"left\">3000 (3 \u0441\u0435\u043a)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">fetch.max.bytes<\/p>\n<\/td>\n<td data-colwidth=\"257\" width=\"257\">\n<p align=\"left\">\u041c\u0430\u043a\u0441. \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 (\u0431\u0430\u0439\u0442)<\/p>\n<\/td>\n<td>\n<p align=\"left\">int<\/p>\n<\/td>\n<td>\n<p align=\"left\">52428800 (50MB)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">fetch.min.bytes<\/p>\n<\/td>\n<td data-colwidth=\"257\" width=\"257\">\n<p align=\"left\">\u041c\u0438\u043d. \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 (\u0431\u0430\u0439\u0442)<\/p>\n<\/td>\n<td>\n<p align=\"left\">int<\/p>\n<\/td>\n<td>\n<p align=\"left\">1<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\"><a href=\"http:\/\/fetch.max.wait.ms\">fetch.max.wait.ms<\/a><\/p>\n<\/td>\n<td data-colwidth=\"257\" width=\"257\">\n<p align=\"left\">\u041c\u0430\u043a\u0441. \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 (\u043c\u0441)<\/p>\n<\/td>\n<td>\n<p align=\"left\">int<\/p>\n<\/td>\n<td>\n<p align=\"left\">500<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h2>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0437\u0430\u043c\u0435\u0442\u043a\u0438<\/h2>\n<ul>\n<li>\n<p><strong>\u0418\u0434\u0435\u043c\u043f\u043e\u0442\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u044c<\/strong>. \u0414\u043b\u044f <code>enable.idempotence=true<\/code> \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f <code>acks=all<\/code> \u0438 <code>retries &gt; 0<\/code>.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/strong>. \u0423\u0432\u0435\u043b\u0438\u0447\u044c\u0442\u0435 <code>batch.size<\/code> \u0438 <a href=\"http:\/\/linger.ms\"><code>linger.ms<\/code><\/a> \u0434\u043b\u044f \u043f\u0440\u043e\u0434\u044e\u0441\u0435\u0440\u0430 \u0438\u043b\u0438 <code>max.poll.records<\/code> \u0434\u043b\u044f \u043a\u043e\u043d\u0441\u044e\u043c\u0435\u0440\u0430, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043d\u0443\u044e \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p><strong>\u041d\u0430\u0434\u0451\u0436\u043d\u043e\u0441\u0442\u044c<\/strong>. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <code>acks=all<\/code> \u0438 \u0432\u044b\u0441\u043e\u043a\u0438\u0439 <code>retries<\/code> \u0434\u043b\u044f \u043f\u0440\u043e\u0434\u044e\u0441\u0435\u0440\u0430, \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u0435 <a href=\"http:\/\/enable.auto\"><code>enable.auto<\/code><\/a><code>.commit<\/code> \u0434\u043b\u044f \u0442\u043e\u0447\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u043e\u0444\u0444\u0441\u0435\u0442\u043e\u0432 \u0432 \u043a\u043e\u043d\u0441\u044e\u043c\u0435\u0440\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>\u041e\u0442\u043b\u0430\u0434\u043a\u0430<\/strong>. \u041b\u043e\u0433\u0438\u0440\u0443\u0439\u0442\u0435 <a href=\"http:\/\/group.id\"><code>group.id<\/code><\/a> \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0439\u0442\u0435 <code>auto.offset.reset<\/code>, \u0435\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435 \u0447\u0438\u0442\u0430\u044e\u0442\u0441\u044f.<\/p>\n<\/li>\n<\/ul>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 kafka-spring-boot-starter \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u043e \u043c\u043d\u0435 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044e Kafka \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u044b \u043d\u0430 Spring Boot. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 Avro \u0438 \u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u043d\u0430\u0443\u0447\u0438\u043b\u0438 \u043c\u0435\u043d\u044f \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u0438 \u0438 \u0432\u0430\u0436\u043d\u043e\u0441\u0442\u0438 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u044d\u0442\u043e\u0442 \u043e\u043f\u044b\u0442 \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u0438\u0442 \u0432\u0430\u0441 \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a!<\/p>\n<p><strong>\u0412\u043e\u043f\u0440\u043e\u0441 \u043a \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f\u043c<\/strong>: \u043a\u0430\u043a\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u044b \u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0432 \u0442\u0430\u043a\u043e\u0439 \u0441\u0442\u0430\u0440\u0442\u0435\u0440? \u0414\u0435\u043b\u0438\u0442\u0435\u0441\u044c \u0438\u0434\u0435\u044f\u043c\u0438 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445!<\/p>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0432\u043d\u0435\u0434\u0440\u0438\u0442\u044c \u0441\u0442\u0430\u0440\u0442\u0435\u0440 \u0432 \u0441\u0432\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442! \u041a\u0430\u043a\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432\u044b \u0440\u0435\u0448\u0430\u0435\u0442\u0435 \u0441 Kafka? \u0414\u0435\u043b\u0438\u0442\u0435\u0441\u044c \u043e\u043f\u044b\u0442\u043e\u043c \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u2014 \u043e\u0431\u0441\u0443\u0434\u0438\u043c, \u043a\u0430\u043a \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434!<\/p>\n<p>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043d\u0430 GitHub  <a href=\"https:\/\/github.com\/bigbox89\/kafka-spring-boot-starter\">https:\/\/github.com\/bigbox89\/kafka-spring-boot-starter<\/a> . \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043f\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u0438\u043b\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e, \u043f\u0438\u0448\u0438\u0442\u0435 \u2014 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435!<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><\/p>\n<div class=\"tm-article-poll-container\"><!--[--><\/p>\n<div class=\"tm-article-poll tm-article-poll_variant-bordered\">\n<div class=\"tm-notice tm-notice_positive tm-article-poll__notice\"><!----><\/p>\n<div class=\"tm-notice__inner\"><!----><\/p>\n<div class=\"tm-notice__content\" data-test-id=\"notice-content\"><!--[--><span>\u0422\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u043f\u0440\u043e\u0441\u0435. <a rel=\"nofollow\" href=\"\/kek\/v1\/auth\/habrahabr\/?back=\/ru\/companies\/sberbank\/articles\/894402\/&#038;hl=ru\">\u0412\u043e\u0439\u0434\u0438\u0442\u0435<\/a>, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430.<\/span><!--]--><\/div>\n<\/div>\n<\/div>\n<p><!--[--><\/p>\n<div class=\"tm-article-poll__header\">\u041f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u0435\u0442\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0442\u0430\u0440\u0442\u0435\u0440\u044b \u0441\u0430\u043c\u0438 \u0438\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435\u0441\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u043c\u0438?<\/div>\n<div class=\"tm-article-poll__answers\"><!--[--><\/p>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent tm-article-poll__answer-percent_winning\">100% <\/span><span class=\"tm-article-poll__answer-label\">\u0434\u0430<\/span><span class=\"tm-article-poll__answer-votes\">2<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress tm-article-poll__answer-progress_winning\" style=\"width: 100%\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">0% <\/span><span class=\"tm-article-poll__answer-label\">\u043d\u0435\u0442<\/span><span class=\"tm-article-poll__answer-votes\">0<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width: 0%\"><\/div>\n<\/div>\n<\/div>\n<p><!--]--><\/div>\n<div class=\"tm-article-poll__stats\"> \u041f\u0440\u043e\u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043b\u0438 2 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.    \u0412\u043e\u0437\u0434\u0435\u0440\u0436\u0430\u043b\u0438\u0441\u044c 2 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. <\/div>\n<p><!--]--><\/div>\n<p><!--]--><\/div>\n<p> \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\/articles\/894402\/\"> https:\/\/habr.com\/ru\/articles\/894402\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\">\n<div><figcaption>Kafka Spring Boot Starter Step By Step<\/figcaption><\/div>\n<\/figure>\n<p>Apache Kafka\u00a0\u2014 \u043c\u043e\u0449\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f\u00a0\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u00a0\u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043d\u043e\u00a0\u0435\u0433\u043e \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f \u0432\u00a0\u043f\u0440\u043e\u0435\u043a\u0442\u044b \u043d\u0430\u00a0Spring Boot \u043c\u043e\u0436\u0435\u0442\u00a0\u0431\u044b\u0442\u044c \u043d\u0435\u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439<\/p>\n<p>\u0412\u00a0\u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0432\u044b \u0443\u0437\u043d\u0430\u0435\u0442\u0435 \u043e\u00a0\u043b\u0443\u0447\u0448\u0438\u0445 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0442\u0430\u0440\u0442\u0435\u0440\u043e\u0432 <strong>Spring Boot Starter \u0434\u043b\u044f\u00a0Kafka \u0441\u00a0\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 Avro<\/strong>, \u0430\u00a0\u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u00a0\u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438. \u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c,\u00a0\u0436\u0435\u043b\u0430\u044e\u0449\u0438\u043c \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441\u00a0Kafka, \u0438 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432, \u0438\u0449\u0443\u0449\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432. \u0414\u043e\u0447\u0438\u0442\u0430\u0432\u0448\u0438\u043c \u0441\u0442\u0430\u0442\u044c\u044e \u0434\u043e\u00a0\u043a\u043e\u043d\u0446\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0439 \u0431\u043e\u043d\u0443\u0441. <\/p>\n<p>\u042f \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043e\u043f\u044b\u0442\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044e Kafka \u0432\u00a0Spring Boot, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0433\u0438\u0431\u043a\u0443\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 Avro.<\/p>\n<ul>\n<li>\n<p><strong>\u0423\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/strong>. \u041c\u043d\u043e\u0433\u0438\u0435 \u0441\u0442\u0430\u0440\u0442\u0435\u0440\u044b \u0434\u043b\u044f\u00a0Kafka \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442, \u043d\u043e\u00a0\u043c\u043e\u0439 \u0444\u043e\u043a\u0443\u0441\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0430\u00a0enterprise\u2011\u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445 (\u0438\u0434\u0435\u043c\u043f\u043e\u0442\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u044c, \u0440\u0435\u0442\u0440\u0430\u0438) \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u0441\u0445\u0435\u043c\u044b Avro \u0447\u0435\u0440\u0435\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u043e\u0447\u0435\u043c\u0443 \u043c\u043d\u0435 \u0432\u0435\u0440\u044f\u0442<\/strong>. \u042f \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e \u043f\u0440\u043e\u0446\u0435\u0441\u0441, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0438 \u0438 \u0438\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u0430\u00a0\u0442\u0430\u043a\u0436\u0435 \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u044e \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043a\u043e\u0434.<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430<\/strong>. \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 Kafka \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0447\u0430\u0441\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043c\u043d\u043e\u0433\u043e boilerplate-\u043a\u043e\u0434\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>\u0426\u0435\u043b\u044c.<\/strong> \u0414\u0430\u0442\u044c \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044e \u0433\u043e\u0442\u043e\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0438 \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u0438\u0442\u044c \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0430\u0440\u0442\u0435\u0440\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<h2>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 Spring Boot Starter?<\/h2>\n<p>Spring Boot Starter \u2014 \u044d\u0442\u043e \u043c\u043e\u0434\u0443\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0433\u043e\u0442\u043e\u0432\u0443\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, spring-boot-starter-web \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440, \u0430 spring-boot-starter-data-jpa \u2014 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u041d\u0430\u0448 \u0441\u0442\u0430\u0440\u0442\u0435\u0440 \u0431\u0443\u0434\u0435\u0442:<\/p>\n<ul>\n<li>\n<p>\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c <code>KafkaProducer<\/code> \u0438 <code>KafkaConsumer<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Avro \u0434\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439;<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0447\u0435\u0440\u0435\u0437 application.yml.<\/p>\n<\/li>\n<\/ul>\n<h2>\u042d\u0442\u0430\u043f\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438<\/h2>\n<p>\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u043a\u043b\u044e\u0447\u0430\u043b \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0430\u0432\u0442\u043e\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0434\u044e\u0441\u0435\u0440\u0430 \u0438 \u043a\u043e\u043d\u0441\u044e\u043c\u0435\u0440\u0430 Kafka. \u0412\u043e\u0442 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0448\u0430\u0433\u0438:<\/p>\n<ol>\n<li>\n<p><strong>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439<\/strong>: <\/p>\n<ul>\n<li>\n<p>Spring Boot \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438;<\/p>\n<\/li>\n<li>\n<p>Spring Kafka \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Kafka;<\/p>\n<\/li>\n<li>\n<p>Apache Avro \u0434\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 (\u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e).<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 KafkaProperties<\/strong>: <\/p>\n<ul>\n<li>\n<p>\u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0438\u0437 application.yml \u0441 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u043c <code>apppetr.kafka<\/code>.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u0410\u0432\u0442\u043e\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f<\/strong>: <\/p>\n<ul>\n<li>\n<p>\u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 <code>KafkaTemplate<\/code> \u0434\u043b\u044f \u043f\u0440\u043e\u0434\u044e\u0441\u0435\u0440\u0430 \u0438 <code>ConcurrentKafkaListenerContainerFactory<\/code> \u0434\u043b\u044f \u043a\u043e\u043d\u0441\u044e\u043c\u0435\u0440\u0430.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 Avro<\/strong>: <\/p>\n<ul>\n<li>\n<p>\u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Avro \u0434\u043b\u044f \u0441\u0442\u0440\u043e\u0433\u043e\u0439 \u0442\u0438\u043f\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0441\u0445\u0435\u043c\u0443 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u0441\u0442\u0430\u0440\u0442\u0435\u0440\u0430.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432<\/h3>\n<p>\u0414\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0441\u0442\u0430\u0440\u0442\u0435\u0440\u0430 \u0447\u0435\u0440\u0435\u0437 application.yml \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441 <code>KafkaProperties<\/code> \u0432 kafka-starter\/src\/main\/java\/com\/app\/petr\/KafkaProperties.java:<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">package com.app.petr;  import org.springframework.boot.context.properties.ConfigurationProperties;  import java.util.HashMap; import java.util.Map;  @ConfigurationProperties(prefix = \"apppetr.kafka\") public class KafkaProperties {     private String bootstrapServers = \"localhost:9092\";     private Producer producer = new Producer();     private Consumer consumer = new Consumer();     private String avroSchemaPath;       public static class Producer {         private String topic = \"default-topic\";         private boolean idempotenceEnabled = true; \/\/ \u0418\u0434\u0435\u043c\u043f\u043e\u0442\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0441\u0442\u0438         private int acks = 1; \/\/ \u041f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f: 0, 1, all         private int retries = 3; \/\/ \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043f\u044b\u0442\u043e\u043a \u043f\u0440\u0438 \u0441\u0431\u043e\u044f\u0445         private int retryBackoffMs = 1000; \/\/ \u0417\u0430\u0434\u0435\u0440\u0436\u043a\u0430 \u043c\u0435\u0436\u0434\u0443 \u0440\u0435\u0442\u0440\u0430\u044f\u043c\u0438         private int deliveryTimeoutMs = 120000; \/\/ \u0422\u0430\u0439\u043c\u0430\u0443\u0442 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438         private int requestTimeoutMs = 30000; \/\/ \u0422\u0430\u0439\u043c\u0430\u0443\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430         private int maxInFlightRequests = 5; \/\/ \u041c\u0430\u043a\u0441. \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u0435\u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432         private Map&lt;String, Object&gt; config = new HashMap&lt;&gt;(); \/\/ \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438          public String getTopic() { return topic; }         public void setTopic(String topic) { this.topic = topic; }         public boolean isIdempotenceEnabled() { return idempotenceEnabled; }         public void setIdempotenceEnabled(boolean idempotenceEnabled) { this.idempotenceEnabled = idempotenceEnabled; }         public int getAcks() { return acks; }         public void setAcks(int acks) { this.acks = acks; }         public int getRetries() { return retries; }         public void setRetries(int retries) { this.retries = retries; }         public int getRetryBackoffMs() { return retryBackoffMs; }         public void setRetryBackoffMs(int retryBackoffMs) { this.retryBackoffMs = retryBackoffMs; }         public int getDeliveryTimeoutMs() { return deliveryTimeoutMs; }         public void setDeliveryTimeoutMs(int deliveryTimeoutMs) { this.deliveryTimeoutMs = deliveryTimeoutMs; }         public int getRequestTimeoutMs() { return requestTimeoutMs; }         public void setRequestTimeoutMs(int requestTimeoutMs) { this.requestTimeoutMs = requestTimeoutMs; }         public int getMaxInFlightRequests() { return maxInFlightRequests; }         public void setMaxInFlightRequests(int maxInFlightRequests) { this.maxInFlightRequests = maxInFlightRequests; }         public Map&lt;String, Object&gt; getConfig() { return config; }         public void setConfig(Map&lt;String, Object&gt; config) { this.config = config; }     }      public static class Consumer {         private String topic = \"default-topic\";         private String groupId = \"default-group\";         private int maxPollRecords = 500; \/\/ \u041c\u0430\u043a\u0441. \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0437\u0430 \u043e\u0434\u0438\u043d poll         private int maxPollIntervalMs = 300000; \/\/ \u041c\u0430\u043a\u0441. \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u043c\u0435\u0436\u0434\u0443 poll         private int sessionTimeoutMs = 10000; \/\/ \u0422\u0430\u0439\u043c\u0430\u0443\u0442 \u0441\u0435\u0441\u0441\u0438\u0438         private int heartbeatIntervalMs = 3000; \/\/ \u0418\u043d\u0442\u0435\u0440\u0432\u0430\u043b heartbeat         private int fetchMaxBytes = 52428800; \/\/ \u041c\u0430\u043a\u0441. \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 (50MB)         private boolean autoCommitEnabled = true; \/\/ \u0410\u0432\u0442\u043e\u043a\u043e\u043c\u043c\u0438\u0442 \u043e\u0444\u0444\u0441\u0435\u0442\u043e\u0432         private int autoCommitIntervalMs = 5000; \/\/ \u0418\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0430\u0432\u0442\u043e\u043a\u043e\u043c\u043c\u0438\u0442\u0430         private String autoOffsetReset = \"earliest\"; \/\/ \u0421\u0431\u0440\u043e\u0441 \u043e\u0444\u0444\u0441\u0435\u0442\u0430         private int retryBackoffMs = 1000; \/\/ \u0417\u0430\u0434\u0435\u0440\u0436\u043a\u0430 \u043c\u0435\u0436\u0434\u0443 \u0440\u0435\u0442\u0440\u0430\u044f\u043c\u0438         private int maxRetries = 3; \/\/ \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0435\u0442\u0440\u0430\u0435\u0432         private Map&lt;String, Object&gt; config = new HashMap&lt;&gt;(); \/\/ \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438          public String getTopic() { return topic; }         public void setTopic(String topic) { this.topic = topic; }         public String getGroupId() { return groupId; }         public void setGroupId(String groupId) { this.groupId = groupId; }         public int getMaxPollRecords() { return maxPollRecords; }         public void setMaxPollRecords(int maxPollRecords) { this.maxPollRecords = maxPollRecords; }         public int getMaxPollIntervalMs() { return maxPollIntervalMs; }         public void setMaxPollIntervalMs(int maxPollIntervalMs) { this.maxPollIntervalMs = maxPollIntervalMs; }         public int getSessionTimeoutMs() { return sessionTimeoutMs; }         public void setSessionTimeoutMs(int sessionTimeoutMs) { this.sessionTimeoutMs = sessionTimeoutMs; }         public int getHeartbeatIntervalMs() { return heartbeatIntervalMs; }         public void setHeartbeatIntervalMs(int heartbeatIntervalMs) { this.heartbeatIntervalMs = heartbeatIntervalMs; }         public int getFetchMaxBytes() { return fetchMaxBytes; }         public void setFetchMaxBytes(int fetchMaxBytes) { this.fetchMaxBytes = fetchMaxBytes; }         public boolean isAutoCommitEnabled() { return autoCommitEnabled; }         public void setAutoCommitEnabled(boolean autoCommitEnabled) { this.autoCommitEnabled = autoCommitEnabled; }         public int getAutoCommitIntervalMs() { return autoCommitIntervalMs; }         public void setAutoCommitIntervalMs(int autoCommitIntervalMs) { this.autoCommitIntervalMs = autoCommitIntervalMs; }         public String getAutoOffsetReset() { return autoOffsetReset; }         public void setAutoOffsetReset(String autoOffsetReset) { this.autoOffsetReset = autoOffsetReset; }         public int getRetryBackoffMs() { return retryBackoffMs; }         public void setRetryBackoffMs(int retryBackoffMs) { this.retryBackoffMs = retryBackoffMs; }         public int getMaxRetries() { return maxRetries; }         public void setMaxRetries(int maxRetries) { this.maxRetries = maxRetries; }         public Map&lt;String, Object&gt; getConfig() { return config; }         public void setConfig(Map&lt;String, Object&gt; config) { this.config = config; }     }      public String getBootstrapServers() { return bootstrapServers; }     public void setBootstrapServers(String bootstrapServers) { this.bootstrapServers = bootstrapServers; }     public Producer getProducer() { return producer; }     public void setProducer(Producer producer) { this.producer = producer; }     public Consumer getConsumer() { return consumer; }     public void setConsumer(Consumer consumer) { this.consumer = consumer; }      public String getAvroSchemaPath() {         return avroSchemaPath;     }      public void setAvroSchemaPath(String avroSchemaPath) {         this.avroSchemaPath = avroSchemaPath;     }  }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b Kafka \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"java\">apppetr:   kafka:     bootstrap-servers: localhost:9092     producer:       topic: test-topic       idempotence-enabled: true       acks: all       retries: 5       retry-backoff-ms: 2000       delivery-timeout-ms: 120000       request-timeout-ms: 30000       max-in-flight-requests: 5     consumer:       topic: test-topic       group-id: test-group       max-poll-records: 1000       max-poll-interval-ms: 600000       session-timeout-ms: 15000       heartbeat-interval-ms: 5000       fetch-max-bytes: 52428800       auto-commit-enabled: true       auto-commit-interval-ms: 5000       auto-offset-reset: earliest       retry-backoff-ms: 2000       max-retries: 5     avro-schema-path: ${project.basedir}\/src\/main\/resources\/avro\/message.avdl<\/code><\/pre>\n<h3>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0430\u0432\u0442\u043e\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438<\/h3>\n<p>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441\u0442\u0430\u0440\u0442\u0435\u0440\u0430 \u2014 \u043a\u043b\u0430\u0441\u0441 \u0430\u0432\u0442\u043e\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 <code>KafkaAutoConfiguration<\/code> \u0432 kafka-starter\/src\/main\/java\/com\/app\/petr\/KafkaAutoConfiguration.java:<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">package com.app.petr;  import org.apache.kafka.clients.consumer.ConsumerConfig; import org.apache.kafka.clients.producer.ProducerConfig; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import<\/code><\/pre>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-453341","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/453341","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=453341"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/453341\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=453341"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=453341"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=453341"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}