{"id":313041,"date":"2020-11-12T15:01:14","date_gmt":"2020-11-12T15:01:14","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=313041"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=313041","title":{"rendered":"Apache Kafka \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441 Kafka Server"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\n<h1 id=\"vvedenie\">\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h1>\n<p>  <\/p>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Apache Kafka. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/www.testcontainers.org\/\">TestContainers<\/a> \u0438 EmbeddedKafka. \u041e\u0431 \u044d\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0432\u043e\u0442 \u0437\u0434\u0435\u0441\u044c: <a href=\"https:\/\/habr.com\/ru\/company\/jugru\/blog\/499408\/\">\u041f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0435 \u043a\u0430\u043c\u043d\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f Kafka Streams<\/a>. \u041d\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c KafkaServer. <\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h1 id=\"chto-budet-testirovatsya\">\u0427\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f?<\/h1>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043f\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c \u043a\u0430\u043d\u0430\u043b\u0430\u043c: email, telegram \u0438 \u0442.\u043f.<\/p>\n<p>  <\/p>\n<p>\u041f\u0443\u0441\u0442\u044c \u0438\u043c\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0431\u0443\u0434\u0435\u0442: SenderService.<\/p>\n<p>  <\/p>\n<p>\u0421\u0435\u0440\u0432\u0438\u0441 \u0434\u043e\u043b\u0436\u0435\u043d: \u0441\u043b\u0443\u0448\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u043a\u0430\u043d\u0430\u043b, \u0432\u044b\u0434\u0435\u043b\u044f\u0442\u044c \u0438\u0437 \u043a\u0430\u043d\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u044b\u0435 \u0435\u043c\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043e \u043d\u0443\u0436\u043d\u043e\u043c\u0443 \u043a\u0430\u043d\u0430\u043b\u0443 \u0434\u043b\u044f \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043a\u0430\u043d\u0430\u043b\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043f\u043e\u0447\u0442\u044b \u0438 \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0431\u044b\u043b\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043e \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u043a\u0430\u043d\u0430\u043b.<br \/>  \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445 \u0442\u0435\u0441\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u0441\u043b\u043e\u0436\u043d\u0435\u0435. \u041d\u043e \u0434\u043b\u044f \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430, \u0442\u0430\u043a\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e.<\/p>\n<p>  <\/p>\n<p>\u0421\u0435\u0440\u0432\u0438\u0441 \u0438 \u0442\u0435\u0441\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c: Java 1.8, Kafka 2.1.0, JUnit 5.5.2, Maven 3.6.1.<\/p>\n<p>  <\/p>\n<h1 id=\"servis\">\u0421\u0435\u0440\u0432\u0438\u0441<\/h1>\n<p>  <\/p>\n<p>\u0421\u0435\u0440\u0432\u0438\u0441 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0447\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0438 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u044e \u0440\u0430\u0431\u043e\u0442\u0443.<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">void start()  void stop()<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u0434\u0430\u0442\u044c, \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">String bootstrapServers String senderTopic EmailService emailService<\/code><\/pre>\n<p>  <\/p>\n<p>bootstrapServers \u2013 \u0430\u0434\u0440\u0435\u0441 kafka.<br \/>  senderTopic \u2013 \u0442\u043e\u043f\u0438\u043a, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0443\u0442 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f.<br \/>  emailService \u2013 \u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043f\u043e \u043f\u043e\u0447\u0442\u0435. <\/p>\n<p>  <\/p>\n<p>\u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u0435 \u0442\u0430\u043a\u0438\u0445 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0436\u0435 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0445 \u043a\u0430\u043d\u0430\u043b\u043e\u0432 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439.<\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u00ab\u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044c\u00bb, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043b\u0443\u0448\u0430\u0435\u0442 \u043a\u0430\u043d\u0430\u043b, \u0444\u0438\u043b\u044c\u0442\u0440\u0443\u0435\u0442 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0435 \u043a\u0430\u043d\u0430\u043b\u044b. \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u0430\u043a\u0438\u0445 \u00ab\u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0435\u0439\u00bb \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c. \u041f\u043e\u0434\u0445\u043e\u0434 \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u00ab\u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044f\u00bb \u043e\u043f\u0438\u0441\u0430\u043d \u0432\u043e\u0442 \u0437\u0434\u0435\u0441\u044c: <a href=\"https:\/\/www.confluent.io\/blog\/tutorial-getting-started-with-the-new-apache-kafka-0-9-consumer-client\/\">Introducing the Kafka Consumer: Getting Started with the New Apache Kafka 0.9 Consumer Client<\/a>.<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">Collection&lt;AutoCloseable&gt; closeables = new ArrayList&lt;&gt;(); ExecutorService senderTasksExecutor = Executors.newFixedThreadPool(senderTasksN); ExecutorService tasksExecutorService = Executors.newFixedThreadPool(tasksN); for (int i = 0; i &lt; senderTasksN; i++) {     SenderConsumerLoop senderConsumerLoop =             new SenderConsumerLoop(                     bootstrapServers,                     senderTopic,                     &quot;sender&quot;,                     &quot;sender&quot;,                     tasksExecutorService,                     emailService             );     closeables.add(senderConsumerLoop);     senderTasksExecutor.submit(senderConsumerLoop); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0446\u0438\u043a\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u00ab\u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044f\u00bb, \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0441\u0435\u0440\u0432\u0438\u0441 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0437\u0430\u0434\u0430\u0447.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u00ab\u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0438\u00bb \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u0421\u0435\u0440\u0432\u0438\u0441 \u0436\u0434\u0435\u0442 \u0438\u0445 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u0434\u043b\u044f \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438.<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">Runtime.getRuntime().addShutdownHook(new Thread(() -&gt; {     for (AutoCloseable autoCloseable : closeables) {         try {             autoCloseable.close();         } catch (Exception e) {             e.printStackTrace();         }     }     senderTasksExecutor.shutdown();     tasksExecutorService.shutdown();     stop();     try {         senderTasksExecutor.awaitTermination(5000, TimeUnit.MILLISECONDS);     } catch (InterruptedException e) {         e.printStackTrace();     } }));<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442\u044c \u0440\u0435\u0441\u0443\u0440\u0441\u044b. <\/p>\n<p>  <\/p>\n<h1 id=\"potrebitel\">\u00ab\u041f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044c\u00bb<\/h1>\n<p>  <\/p>\n<p>\u00ab\u041f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044c\u00bb \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">void run()  void close()<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043c\u0435\u0442\u043e\u0434: run.<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">@Override public void run() {     kafkaConsumer = createKafkaConsumerStringString(bootstrapServers, clientId, groupId);     kafkaConsumer.subscribe(Collections.singleton(topic));     while (true) {         calculate(kafkaConsumer.poll(Duration.ofSeconds(1)));     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e \u0432\u0445\u043e\u0434\u043d\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u00abkafka-\u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044f\u00bb. \u00abkafka-\u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044c\u00bb \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u0442\u043e\u043f\u0438\u043a. \u0412 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0446\u0438\u043a\u043b\u0435 \u0432\u044b\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0438\u0437 \u0442\u043e\u043f\u0438\u043a\u0430. \u0418 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0446\u0438\u0438 json-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0438 \u0442\u0438\u043f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"json\">{   &quot;subject&quot;: {     &quot;subject_type&quot;: &quot;send&quot;   },   &quot;body&quot;: {     &quot;method&quot;: &quot;email&quot;,     &quot;recipients&quot;: &quot;mrbrown@ml.ml;mrblack@ml.ml;mrwhite@ml.ml&quot;,     &quot;title&quot;: &quot;42&quot;,     &quot;message&quot;: &quot;73&quot;   } }<\/code><\/pre>\n<p>  <\/p>\n<p>subject_type \u2014 \u0442\u0438\u043f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u00absend\u00bb.<br \/>  method \u2013 \u0442\u0438\u043f \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438. \u00abemail\u00bb \u2014 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u043f\u043e\u0447\u0442\u0443.<br \/>  recipients \u2013 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u0435\u0439.<br \/>  title \u2013 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0434\u043b\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f.<br \/>  message \u2013 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435.<\/p>\n<p>  <\/p>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0432\u0441\u0435\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">void calculate(ConsumerRecords&lt;String, String&gt; records) {     for (ConsumerRecord&lt;String, String&gt; record : records) {         calculate(record);     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0434\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">void calculate(ConsumerRecord&lt;String, String&gt; record) {             JSONParser jsonParser = new JSONParser();             Object parsedObject = null;             try {                 parsedObject = jsonParser.parse(record.value());             } catch (ParseException e) {                 e.printStackTrace();             }             if (parsedObject instanceof JSONObject) {                 JSONObject jsonObject = (JSONObject) parsedObject;                 JSONObject jsonSubject = (JSONObject) jsonObject.get(SUBJECT);                 String subjectType = jsonSubject.get(SUBJECT_TYPE).toString();                 if (SEND.equals(subjectType)) {                     JSONObject jsonBody = (JSONObject) jsonObject.get(BODY);                     calculate(jsonBody);                 }             }         }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043f\u043e \u0442\u0438\u043f\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">void calculate(JSONObject jsonBody) {     String method = jsonBody.get(METHOD).toString();     if (EMAIL_METHOD.equals(method)) {         String recipients = jsonBody.get(RECIPIENTS).toString();         String title = jsonBody.get(TITLE).toString();         String message = jsonBody.get(MESSAGE).toString();         sendEmail(recipients, title, message);     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">void sendEmail(String recipients, String title, String message) {     tasksExecutorService.submit(() -&gt; emailService.send(recipients, title, message)); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0447\u0435\u0440\u0435\u0437 \u0441\u0435\u0440\u0432\u0438\u0441 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447.<\/p>\n<p>  <\/p>\n<p>\u041e\u0436\u0438\u0434\u0430\u043d\u0438\u044f \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442.<\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u00abkafka-\u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044f\u00bb:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">static KafkaConsumer&lt;String, String&gt; createKafkaConsumerStringString(         String bootstrapServers,         String clientId,         String groupId ) {     Properties properties = new Properties();     properties.setProperty(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);     properties.setProperty(ConsumerConfig.CLIENT_ID_CONFIG, clientId);     properties.setProperty(ConsumerConfig.GROUP_ID_CONFIG, groupId);     properties.setProperty(             ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG,             &quot;org.apache.kafka.common.serialization.StringDeserializer&quot;);     properties.setProperty(             ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG,             &quot;org.apache.kafka.common.serialization.StringDeserializer&quot;);     properties.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, &quot;earliest&quot;);     return new KafkaConsumer&lt;&gt;(properties); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u043f\u0438\u0441\u0435\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">interface EmailService {     void send(String recipients, String title, String message); }<\/code><\/pre>\n<p>  <\/p>\n<h1 id=\"test\">\u0422\u0435\u0441\u0442<\/h1>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0442\u0435\u0441\u0442\u0430 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435.<br \/>  \u0410\u0434\u0440\u0435\u0441 \u00abkafka-\u0441\u0435\u0440\u0432\u0435\u0440\u0430\u00bb.<br \/>  \u041f\u043e\u0440\u0442 \u0434\u043b\u044f \u00abkafka-\u0441\u0435\u0440\u0432\u0435\u0440\u0430\u00bb.<br \/>  \u0418\u043c\u044f \u0442\u043e\u043f\u0438\u043a\u0430.<\/p>\n<p>  <\/p>\n<p>\u0421\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u00abkafka-\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c\u00bb. \u0411\u0443\u0434\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u043d \u043d\u0438\u0436\u0435.<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">public class SenderServiceTest {     @Test     void consumeEmail() throws InterruptedException {         String brokerHost = &quot;127.0.0.1&quot;;         int brokerPort = 29092;         String bootstrapServers = brokerHost + &quot;:&quot; + brokerPort;         String senderTopic = &quot;sender_data&quot;;         try (KafkaServerService kafkaServerService = new KafkaServerService(brokerHost, brokerPort)) {             kafkaServerService.start();             kafkaServerService.createTopic(senderTopic);          }     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0430\u0434\u0430\u044e\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b. \u0421\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u00abkafka-\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c\u00bb. \u00abkafka-\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c\u00bb \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u0442. \u0421\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u0442\u043e\u043f\u0438\u043a.<\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u00abmock\u00bb \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">SenderService.EmailService emailService = mock(SenderService.EmailService.class);<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0441\u0430\u043c \u0441\u0435\u0440\u0432\u0438\u0441 \u0438 \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u0442:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">SenderService senderService = new SenderService(bootstrapServers, senderTopic, emailService); senderService.start();<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0430\u0434\u0430\u044e\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043b\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">String recipients = &quot;mrbrown@ml.ml;mrblack@ml.ml;mrwhite@ml.ml&quot;; String title = &quot;42&quot;; String message = &quot;73&quot;;<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 \u043a\u0430\u043d\u0430\u043b:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">kafkaServerService.send(senderTopic, key(), createMessage(EMAIL_METHOD, recipients, title, message));<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0436\u0438\u0434\u0430\u043d\u0438\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">Thread.sleep(6000);<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0447\u0442\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0434\u043e\u0448\u043b\u043e \u0434\u043e \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">verify(emailService).send(recipients, title, message);<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">senderService.stop();<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u0441\u0435 \u0432\u043c\u0435\u0441\u0442\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">public class SenderServiceTest {     @Test     void consumeEmail() throws InterruptedException {         String brokerHost = &quot;127.0.0.1&quot;;         int brokerPort = 29092;         String bootstrapServers = brokerHost + &quot;:&quot; + brokerPort;         String senderTopic = &quot;sender_data&quot;;         try (KafkaServerService kafkaServerService = new KafkaServerService(brokerHost, brokerPort)) {             kafkaServerService.start();             kafkaServerService.createTopic(senderTopic);             SenderService.EmailService emailService = mock(SenderService.EmailService.class);             SenderService senderService = new SenderService(bootstrapServers, senderTopic, emailService);             senderService.start();             String recipients = &quot;mrbrown@ml.ml;mrblack@ml.ml;mrwhite@ml.ml&quot;;             String title = &quot;42&quot;;             String message = &quot;73&quot;;             kafkaServerService.send(senderTopic, key(), createMessage(EMAIL_METHOD, recipients, title, message));             Thread.sleep(6000);             verify(emailService).send(recipients, title, message);             senderService.stop();         }     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">public class SenderFactory {     public static final String SUBJECT = &quot;subject&quot;;     public static final String SUBJECT_TYPE = &quot;subject_type&quot;;     public static final String BODY = &quot;body&quot;;     public static final String METHOD = &quot;method&quot;;     public static final String EMAIL_METHOD = &quot;email&quot;;     public static final String RECIPIENTS = &quot;recipients&quot;;     public static final String TITLE = &quot;title&quot;;     public static final String MESSAGE = &quot;message&quot;;     public static final String SEND = &quot;send&quot;;      public static String key() {         return UUID.randomUUID().toString();     }      public static String createMessage(String method, String recipients, String title, String message) {         Map&lt;String, Object&gt; map = new HashMap&lt;&gt;();         Map&lt;String, Object&gt; subject = new HashMap&lt;&gt;();         Map&lt;String, Object&gt; body = new HashMap&lt;&gt;();         map.put(SUBJECT, subject);         subject.put(SUBJECT_TYPE, SEND);         map.put(BODY, body);         body.put(METHOD, method);         body.put(RECIPIENTS, recipients);         body.put(TITLE, title);         body.put(MESSAGE, message);         return JSONObject.toJSONString(map);     } }<\/code><\/pre>\n<p>  <\/p>\n<h1 id=\"servis-dlya-upravleniya-kafka-serverom\">\u0421\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u00abkafka-\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c\u00bb<\/h1>\n<p>  <\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">void start()  void close()  void createTopic(String topic)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u043c\u0435\u0442\u043e\u0434\u0435 \u00abstart\u00bb \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u00abzookeeper\u00bb \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0435\u0433\u043e \u0430\u0434\u0440\u0435\u0441\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">zkServer = new EmbeddedZookeeper(); String zkConnect = zkHost + &quot;:&quot; + zkServer.port();<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u00abzookeeper\u00bb:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">zkClient = new ZkClient(zkConnect, 30000, 30000, ZKStringSerializer$.MODULE$); zkUtils = ZkUtils.apply(zkClient, false);<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">Properties brokerProps = new Properties(); brokerProps.setProperty(&quot;zookeeper.connect&quot;, zkConnect); brokerProps.setProperty(&quot;broker.id&quot;, &quot;0&quot;); try {     brokerProps.setProperty(&quot;log.dirs&quot;, Files.createTempDirectory(&quot;kafka-&quot;).toAbsolutePath().toString()); } catch (IOException e) {     throw new RuntimeException(e); } brokerProps.setProperty(&quot;listeners&quot;, &quot;PLAINTEXT:\/\/&quot; + brokerHost + &quot;:&quot; + brokerPort); brokerProps.setProperty(&quot;offsets.topic.replication.factor&quot;, &quot;1&quot;); KafkaConfig config = new KafkaConfig(brokerProps);<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">kafkaServer = TestUtils.createServer(config, new MockTime());<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u0441\u0435 \u0432\u043c\u0435\u0441\u0442\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">public void start() {     zkServer = new EmbeddedZookeeper();     String zkConnect = zkHost + &quot;:&quot; + zkServer.port();     zkClient = new ZkClient(zkConnect, 30000, 30000, ZKStringSerializer$.MODULE$);     zkUtils = ZkUtils.apply(zkClient, false);     Properties brokerProps = new Properties();     brokerProps.setProperty(&quot;zookeeper.connect&quot;, zkConnect);     brokerProps.setProperty(&quot;broker.id&quot;, &quot;0&quot;);     try {         brokerProps.setProperty(&quot;log.dirs&quot;, Files.createTempDirectory(&quot;kafka-&quot;).toAbsolutePath().toString());     } catch (IOException e) {         throw new RuntimeException(e);     }     brokerProps.setProperty(&quot;listeners&quot;, &quot;PLAINTEXT:\/\/&quot; + brokerHost + &quot;:&quot; + brokerPort);     brokerProps.setProperty(&quot;offsets.topic.replication.factor&quot;, &quot;1&quot;);     KafkaConfig config = new KafkaConfig(brokerProps);     kafkaServer = TestUtils.createServer(config, new MockTime()); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">@Override public void close() {     kafkaServer.shutdown();     zkClient.close();     zkServer.shutdown(); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u043e\u043f\u0438\u043a\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">public void createTopic(String topic) {     AdminUtils.createTopic(             zkUtils, topic, 1, 1, new Properties(), RackAwareMode.Disabled$.MODULE$); }<\/code><\/pre>\n<p>  <\/p>\n<h1 id=\"zaklyuchenie\">\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h1>\n<p>  <\/p>\n<p>\u0412 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u0437\u0434\u0435\u0441\u044c \u043a\u043e\u0434 \u043b\u0438\u0448\u044c \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u00abkafka\u00bb \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0440\u0435\u0441\u0443\u0440\u0441\u0443:<br \/>  <a href=\"https:\/\/github.com\/confluentinc\/kafka-streams-examples\">kafka-streams-examples<\/a><\/p>\n<p>  <\/p>\n<h1 id=\"ssylki-i-resursy\">\u0421\u0441\u044b\u043b\u043a\u0438 \u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u044b<\/h1>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/kartzum\/intro_to_apache_kafka\/tree\/main\/story\/resources\/k-service\">\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434<\/a> <\/p>\n<p>  <\/p>\n<p><a href=\"https:\/\/gist.github.com\/asmaier\/6465468\">\u041a\u043e\u0434 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441 \u00abkafka-\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c\u00bb<\/a><\/p>\n<\/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\/post\/527712\/\"> https:\/\/habr.com\/ru\/post\/527712\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\n<h1 id=\"vvedenie\">\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h1>\n<p>  <\/p>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Apache Kafka. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/www.testcontainers.org\/\">TestContainers<\/a> \u0438 EmbeddedKafka. \u041e\u0431 \u044d\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0432\u043e\u0442 \u0437\u0434\u0435\u0441\u044c: <a href=\"https:\/\/habr.com\/ru\/company\/jugru\/blog\/499408\/\">\u041f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0435 \u043a\u0430\u043c\u043d\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f Kafka Streams<\/a>. \u041d\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c KafkaServer. <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-313041","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/313041","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=313041"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/313041\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=313041"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=313041"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=313041"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}