{"id":26811,"date":"2020-04-22T00:00:00","date_gmt":"2020-04-21T22:00:00","guid":{"rendered":"https:\/\/blexin.com\/la-metamorfosi-della-comunicazione-con-kafka\/"},"modified":"2021-05-21T20:28:29","modified_gmt":"2021-05-21T18:28:29","slug":"the-metamorphosis-of-communication-with-kafka","status":"publish","type":"post","link":"https:\/\/blexin.com\/en\/blog-en\/the-metamorphosis-of-communication-with-kafka\/","title":{"rendered":"&#8220;The Metamorphosis&#8221; of communication with Kafka"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"608\" data-attachment-id=\"26783\" data-permalink=\"https:\/\/blexin.com\/en\/blog-en\/the-metamorphosis-of-communication-with-kafka\/attachment\/a02436f4-6edd-4491-856a-c1985e9aa754-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/a02436f4-6edd-4491-856a-c1985e9aa754.png?fit=1024%2C608&amp;ssl=1\" data-orig-size=\"1024,608\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"a02436f4-6edd-4491-856a-c1985e9aa754\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/a02436f4-6edd-4491-856a-c1985e9aa754.png?fit=1024%2C608&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/a02436f4-6edd-4491-856a-c1985e9aa754.png?resize=1024%2C608&#038;ssl=1\" alt=\"\" class=\"wp-image-26783\" srcset=\"https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/a02436f4-6edd-4491-856a-c1985e9aa754.png 1024w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/a02436f4-6edd-4491-856a-c1985e9aa754-980x582.png 980w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/a02436f4-6edd-4491-856a-c1985e9aa754-480x285.png 480w\" sizes=\"auto, (min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">In my previous articles, we have seen how useful it is to use communication technologies and solutions such as&nbsp;<a href=\"https:\/\/www.blexin.com\/en-US\/Article\/Blog\/Decoupling-the-communication-with-RabbitMQ-40\" target=\"_blank\" rel=\"noreferrer noopener\">RabbitMQ<\/a>&nbsp;or an ESB (<em>Enterprise Service Bus<\/em>) such as&nbsp;<a href=\"https:\/\/www.blexin.com\/en-US\/Article\/Blog\/Lets-solve-the-rebus-of-communication-56\" target=\"_blank\" rel=\"noreferrer noopener\">Rebus<\/a>, whether they are on-premise or cloud, to decouple communication in software systems.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Not many years ago, in Linkedin they used&nbsp;<a href=\"https:\/\/activemq.apache.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">ActiveMQ<\/a>&nbsp;to try to solve a problem related to real-time access to monitoring and user activities traceability data, which&nbsp; were also related each other. The try was not successful because with&nbsp;<em>ActiveMQ<\/em>&nbsp;they could not scale-out to manage the huge amount of traffic. Therefore, they decided to develop a messaging system that would provide both the persistence of the messages, in order to make them usable for multiple applications, and the chance to scale horizontally in order to manage a large amount of data. Finally, they decided to give it a name of a writer who sounded good, and that was how&nbsp;<em>Kafka<\/em>&nbsp;was born (<a href=\"https:\/\/www.oreilly.com\/library\/view\/kafka-the-definitive\/9781491936153\/ch01.html\" target=\"_blank\" rel=\"noreferrer noopener\">Kafka: The Definitive Guide<\/a>).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Fundamental concepts<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">It was initially created as a &#8220;distributed publish\/subscribe messaging system&#8221; until it evolved into a distributed streaming platform. Basically, we will have a&nbsp;<em>Publisher<\/em>&nbsp;(<em>Producer<\/em>) who publishes messages on a&nbsp;<em>Broker<\/em>&nbsp;(<em>Kafka Broker<\/em>) and a&nbsp;<em>Subscriber<\/em>&nbsp;(<em>Consumer<\/em>) who subscribes to them.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"989\" height=\"431\" data-attachment-id=\"26785\" data-permalink=\"https:\/\/blexin.com\/en\/blog-en\/the-metamorphosis-of-communication-with-kafka\/attachment\/image-0-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image-0.png?fit=989%2C431&amp;ssl=1\" data-orig-size=\"989,431\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-0\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image-0.png?fit=989%2C431&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image-0.png?resize=989%2C431&#038;ssl=1\" alt=\"\" class=\"wp-image-26785\" srcset=\"https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image-0.png 989w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image-0-980x427.png 980w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image-0-480x209.png 480w\" sizes=\"auto, (min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 989px, 100vw\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The&nbsp;<em>message<\/em>&nbsp;is the information unit that travels in Kafka and is nothing more than an array of bytes, which, optionally, can be accompanied by a&nbsp;<em>key<\/em>&nbsp;used to manage the writing of the message. For reasons of efficiency, in Kafka it is generally preferred to transmit messages in&nbsp;<em>batches<\/em>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When a broker receives a message from a producer, he categorizes it into a&nbsp;<em>Topic<\/em>. The topic is the actual representation of the data stream that passes from the producer to the consumer. The topics are, in turn, divided into&nbsp;<em>partitions<\/em>. A partition is an ordered and immutable sequence of messages that are stored one after the other, and that can only be read in the order in which they were written. In fact, the messages will not be sorted within the topic but will be sorted at the partition level, assigning each message a unique&nbsp;<em>id<\/em>&nbsp;called&nbsp;<em>Offset<\/em>. In order to ensure the order of the messages, the partitions are also a tool for redundancy and scalability as they can be replicated within Kafka.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"909\" height=\"623\" data-attachment-id=\"26788\" data-permalink=\"https:\/\/blexin.com\/en\/blog-en\/the-metamorphosis-of-communication-with-kafka\/attachment\/image-1-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image-1.png?fit=909%2C623&amp;ssl=1\" data-orig-size=\"909,623\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-1\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image-1.png?fit=909%2C623&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image-1.png?resize=909%2C623&#038;ssl=1\" alt=\"\" class=\"wp-image-26788\" srcset=\"https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image-1.png 909w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image-1-480x329.png 480w\" sizes=\"auto, (min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 909px, 100vw\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">In fact, the basic idea is that a Kafka broker operates as part of a&nbsp;<em>Cluster<\/em>&nbsp;of brokers running on one or more servers. A cluster is responsible for receiving messages, saving them in topics for a configurable&nbsp;<em>retention period<\/em>&nbsp;and assign the offsets within partitions. The partitions can be replicated within the cluster and for each partition there will be only one broker who will act as&nbsp;<em>leader<\/em>. This last will manage the messages for that partition, while the other brokers on which the partition is replicated will act as&nbsp;<em>followers<\/em>&nbsp;by saving copies passively than the leader. This is very important because if the broker leader fails, one of the followers can be elected leader and thus allow the cluster to run properly.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"830\" height=\"514\" data-attachment-id=\"26791\" data-permalink=\"https:\/\/blexin.com\/en\/blog-en\/the-metamorphosis-of-communication-with-kafka\/attachment\/image-2-2-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image-2.png?fit=830%2C514&amp;ssl=1\" data-orig-size=\"830,514\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-2\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image-2.png?fit=830%2C514&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image-2.png?resize=830%2C514&#038;ssl=1\" alt=\"\" class=\"wp-image-26791\" srcset=\"https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image-2.png 830w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image-2-480x297.png 480w\" sizes=\"auto, (min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 830px, 100vw\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">We said that the messages are published by the&nbsp;<em>Producers<\/em>. In addition to creating the data stream, a Producer can choose which partition to write a particular message through a&nbsp;<em>partitioner<\/em>. The choice is usually based on the message key: if the key is not specified, the partitioner will choose the partition according to a&nbsp;<em>round-robin<\/em>&nbsp;(<em>RR<\/em>) scheduling to balance the load; otherwise, if there is a key, the partitioner will be able to route messages to specific partitions, for example, by hashing the key so that messages with the same hash value are written in the same partition.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As an additional&nbsp;<em>fault-tolerance<\/em>&nbsp;mechanism, one of the brokers within the cluster will play the role of&nbsp;<em>controller<\/em>&nbsp;and will take care of assigning the partitions to the other brokers and supervising the health of the cluster components.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The stream of messages will be consumed by those softwares, the&nbsp;<em>consumers<\/em>, who subscribe to a specific topic and take their messages ordered thanks to the use of the offset we have talked about. In fact, when a consumer starts to consume the messages of a partition, a particular topic is created called&nbsp;<em>_consumer_offsets<\/em>, where he saves the offset of the last message consumed and thus maintaining a state of his reading.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Consumers are also designed to operate as part of a whole, called the&nbsp;<em>Consumer Group<\/em>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A Consumer Group is made up of one or more consumers who work together to consume messages more efficiently within a topic by dividing the partitions equally. In fact, if one of the group&#8217;s consumers fails, its part is distributed among the other consumers. In addition to having multiple consumers within a group, you can also have multiple groups consuming messages from a topic. This fact is very useful when there are multiple applications interested in the messages of a certain topic. The Consumer Group concept allows you to generalize the advantages of traditional messaging systems. As in a queue system, it is possible to divide the processing among various consumers: the various consumer instances within the group do that. As in a publish\/subscribe system, messages can be read by multiple Consumer Groups.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this way, it is possible to guarantee both scalability for processing and reliability for delivery to multiple User Groups and therefore to multiple interested applications. In addition, with the concept of partition, Kafka guarantees the order of messages even with multiple consumers, unlike a more traditional system such as the queue system in which messages are delivered asynchronously and therefore in presence of multiple consumers is not possible to guarantee the order.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Let&#8217;s take an example<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Introduced all the key concepts of Kafka, we see now an example of publish\/subscribe developed in&nbsp;<em>.NET Core<\/em>. For the kafka-server, we will use an image instantiated on a&nbsp;<em>Docker<\/em>&nbsp;container.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In order to let a kafka server run properly, we must first make sure that it is connected to a&nbsp;<em>Zookeeper<\/em>&nbsp;instance. Zookeeper is a centralized service that manages configurations and synchronizations in distributed applications. Kafka uses Zookeeper to save metadata related to brokers, topics and partitions. So let&#8217;s create a container docker for Zookeeper by running the following command from the terminal where we go to specify the port and a server&nbsp;<em>id<\/em>:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\ndocker run --net=kafka \\\n-d \\\n--name=zookeeper \\\n-e ZOOKEEPER_CLIENT_PORT=2181 \\\n-e ZOOKEEPER_SERVER_ID=1 \\\nconfluentinc\/cp-zookeeper:5.4.1\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">After that, we create the container for the Kafka server by specifying the Zookeeper address, an address where to reach Kafka outside the container and the replication value of the topics to be specified in the case of single-node clusters:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndocker run --net=kafka \\\n-d \\\n-p 9092:9092 \\\n--name=kafka \\\n-e KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181 \\\n-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT:\/\/localhost:9092 \\\n-e KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1 \\\nconfluentinc\/cp-kafka:5.4.\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s create a topic with three partitions with the following command:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\ndocker exec -it kafka kafka-topics --bootstrap-server localhost:9092 --create --topic demo-topic --partitions 3\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">to see the result we use instead:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\ndocker exec -it kafka kafka-topics --describe --bootstrap-server localhost:9092\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"641\" height=\"74\" data-attachment-id=\"26795\" data-permalink=\"https:\/\/blexin.com\/en\/blog-en\/the-metamorphosis-of-communication-with-kafka\/attachment\/image-3-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image-3.png?fit=641%2C74&amp;ssl=1\" data-orig-size=\"641,74\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-3\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image-3.png?fit=641%2C74&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image-3.png?resize=641%2C74&#038;ssl=1\" alt=\"\" class=\"wp-image-26795\" srcset=\"https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image-3.png 641w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image-3-480x55.png 480w\" sizes=\"auto, (min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 641px, 100vw\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Once the topic has been created, we create a&nbsp;<em>console application<\/em>&nbsp;that will perform the role of&nbsp;<em>Producer<\/em>. We will use the Kafka&nbsp;<em>client<\/em>&nbsp;for&nbsp;<em>.NET<\/em>,&nbsp;<em>Confluent.Kafka<\/em>, made available by&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/www.confluent.io\/\" target=\"_blank\">Confluent<\/a>.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\nusing System;\nusing System.Threading.Tasks;\nusing Confluent.Kafka;\n\u00a0\nnamespace Kafka.Producer\n{\n\u00a0\u00a0\u00a0\u00a0class Program\n\u00a0\u00a0\u00a0\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0static async Task Main(string&#x5B;] args)\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0var config = new ProducerConfig { BootstrapServers = &quot;localhost:9092&quot;, Partitioner = Partitioner.Random };\n\u00a0\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0using (var producer = new ProducerBuilder&lt;Null, string&gt;(config).Build())\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0try\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0for (int i = 0; i &lt; 5; i++)\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0var deliveryResult = await producer.ProduceAsync(&quot;demo-topic&quot;, new Message&lt;Null, string&gt; { Value = $&quot;DemoMessage &#039;{i}&#039;&quot; });\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Console.WriteLine($&quot;Published message to &#039;{deliveryResult.TopicPartitionOffset}&#039;&quot;);\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0catch (ProduceException&lt;Null, string&gt; e)\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Console.WriteLine($&quot;Error publishing message: {e.Error.Reason}&quot;);\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0}\n}\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">We configure the Producer indicating the address of the Kafka server and the type of Partitioner (in this case&nbsp;<em>Random<\/em>&nbsp;will implement an RR scheduling). Then we create a Producer using the&nbsp;<em>ProducerBuilder<\/em>&nbsp;with null key, since we chose a non-key based partitioner. Using the&nbsp;<em>ProduceAsync<\/em>() method we send the messages on &#8220;demo-topic&#8221; and print the result of the writing in the console in order to display in which partition and in which offset the messages have been saved.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Running the program we get the following result:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"641\" height=\"108\" data-attachment-id=\"26797\" data-permalink=\"https:\/\/blexin.com\/en\/blog-en\/the-metamorphosis-of-communication-with-kafka\/attachment\/image-4-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image-4.png?fit=641%2C108&amp;ssl=1\" data-orig-size=\"641,108\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-4\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image-4.png?fit=641%2C108&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image-4.png?resize=641%2C108&#038;ssl=1\" alt=\"\" class=\"wp-image-26797\" srcset=\"https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image-4.png 641w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image-4-480x81.png 480w\" sizes=\"auto, (min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 641px, 100vw\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">With the following command we go to use the Kafka console consumer, a tool that reads the messages within the topic and reports them on the console:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\ndocker exec -it kafka kafka-console-consumer --bootstrap-server localhost:9092 --topic demo-topic --from-beginning\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"837\" height=\"86\" data-attachment-id=\"26800\" data-permalink=\"https:\/\/blexin.com\/en\/blog-en\/the-metamorphosis-of-communication-with-kafka\/attachment\/image-5-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image-5.png?fit=837%2C86&amp;ssl=1\" data-orig-size=\"837,86\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-5\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image-5.png?fit=837%2C86&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image-5.png?resize=837%2C86&#038;ssl=1\" alt=\"\" class=\"wp-image-26800\" srcset=\"https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image-5.png 837w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image-5-480x49.png 480w\" sizes=\"auto, (min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 837px, 100vw\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">As we can see, the messages are not shown in order because, as we said, the order is at the partition level, not at the topic level. We can see this with the following command related to partition 2:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\ndocker exec -it kafka kafka-console-consumer --bootstrap-server localhost:9092 --topic demo-topic --from-beginning --partition 2\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"934\" height=\"57\" data-attachment-id=\"26803\" data-permalink=\"https:\/\/blexin.com\/en\/blog-en\/the-metamorphosis-of-communication-with-kafka\/attachment\/image-6-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image-6.png?fit=934%2C57&amp;ssl=1\" data-orig-size=\"934,57\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-6\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image-6.png?fit=934%2C57&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image-6.png?resize=934%2C57&#038;ssl=1\" alt=\"\" class=\"wp-image-26803\" srcset=\"https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image-6.png 934w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image-6-480x29.png 480w\" sizes=\"auto, (min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 934px, 100vw\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">As we can see they are ordered. Let&#8217;s now create the consumer application:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\nusing System;\nusing Confluent.Kafka;\n\u00a0\nclass Program\n{\n\u00a0\u00a0\u00a0\u00a0public static void Main(string&#x5B;] args)\n\u00a0\u00a0\u00a0\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0var conf = new ConsumerConfig\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0GroupId = &quot;demo-consumer-group&quot;,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0BootstrapServers = &quot;localhost:9092&quot;,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0AutoOffsetReset = AutoOffsetReset.Earliest\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0};\n\u00a0\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0using (var consumer = new ConsumerBuilder&lt;Ignore, string&gt;(conf).Build())\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0consumer.Subscribe(&quot;demo-topic&quot;);\n\u00a0\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0var readingMessage = true;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0try\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0while (readingMessage)\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0try\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0var consumeResult = consumer.Consume(10000);\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if (consumeResult == null)\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Console.WriteLine(&quot;There are no messages in topic&quot;);\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0readingMessage = false;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0else\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Console.WriteLine($&quot;Consumed message &#039;{consumeResult.Message.Value}&#039; at: &#039;{consumeResult.TopicPartitionOffset}&#039;.&quot;);\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0catch (ConsumeException e)\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Console.WriteLine($&quot;Error occured: {e.Error.Reason}&quot;);\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0catch (OperationCanceledException)\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{\n\u00a0\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0consumer.Close();\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0}\n}\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">We configure the consumer by indicating the Consumer Group, the address of the Kafka server and specifying what action to take when there is no initial offset. We create the consumer and subscribe it to our topic, then we start reading the topic until the&nbsp;<em>timeout<\/em>&nbsp;specified through the&nbsp;<em>Consume<\/em>&nbsp;method. We print the result of the reading in the console and finally with the&nbsp;<em>Close<\/em>&nbsp;method we commit the offsets on Kafka, alerting that the consumer is leaving the group.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">By running the Consumer, we can see that all published messages have been consumed correctly.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"565\" height=\"123\" data-attachment-id=\"26805\" data-permalink=\"https:\/\/blexin.com\/en\/blog-en\/the-metamorphosis-of-communication-with-kafka\/attachment\/image-7-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image-7.png?fit=565%2C123&amp;ssl=1\" data-orig-size=\"565,123\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-7\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image-7.png?fit=565%2C123&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image-7.png?resize=565%2C123&#038;ssl=1\" alt=\"\" class=\"wp-image-26805\" srcset=\"https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image-7.png 565w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image-7-480x104.png 480w\" sizes=\"auto, (min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 565px, 100vw\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>The Kafka ecosystem<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is just an overview of the core features of Kafka, which has become a real ecosystem over the years. In fact, in addition to the exchange of messages between producer and consumer, there are two further features:&nbsp;<em>Kafka Connect<\/em>&nbsp;and&nbsp;<em>Kafka Stream<\/em>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"861\" data-attachment-id=\"26808\" data-permalink=\"https:\/\/blexin.com\/en\/blog-en\/the-metamorphosis-of-communication-with-kafka\/attachment\/image-8-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image-8.png?fit=1069%2C899&amp;ssl=1\" data-orig-size=\"1069,899\" data-comments-opened=\"0\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-8\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image-8.png?fit=1024%2C861&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/image-8.png?resize=1024%2C861&#038;ssl=1\" alt=\"\" class=\"wp-image-26808\" srcset=\"https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image-8-1024x861.png 1024w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image-8-980x824.png 980w, https:\/\/blexin.com\/wp-content\/uploads\/2020\/12\/image-8-480x404.png 480w\" sizes=\"auto, (min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The first is a framework for the data transfer of heterogeneous systems through Kafka which provides well-defined APIs to implement so-called&nbsp;<em>connectors<\/em>. Think about the variation of the field of a table of a database notified through Kafka: this is possible through a database connector to Kafka.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Instead, the second feature is a library for creating streaming applications, that is applications that transform Kafka input topics into output topics.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Conclusions<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Hoping that this introduction has been interesting to enter the Kafka ecosystem, I leave you the link of the&nbsp;<a href=\"https:\/\/github.com\/intersect88\/IntroToKafka\" target=\"_blank\" rel=\"noreferrer noopener\">repository<\/a>&nbsp;where you can find the producer and consumer implementation, as well as the commands to create the containers for Kafka and Zookeeper.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">See you next time!<\/p>\n\n\n\n\n","protected":false},"excerpt":{"rendered":"<p>Let\u2019s discover Kafka by introducing the fundamental concepts and showing an example in .NET Core<\/p>\n","protected":false},"author":196716251,"featured_media":26783,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"off","_et_pb_old_content":"","_et_gb_content_width":"","_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","inline_featured_image":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"{title}\n\n{excerpt}\n\n{url}","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_wpas_customize_per_network":false,"jetpack_post_was_ever_published":false},"categories":[688637524],"tags":[688637542,688637546,688637438,688637537],"class_list":["post-26811","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog-en","tag-dotnetcore-en","tag-docker-en","tag-kafka-en","tag-swdesign-en"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>&quot;The Metamorphosis&quot; of communication with Kafka - Blexin<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blexin.com\/en\/blog-en\/the-metamorphosis-of-communication-with-kafka\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"&quot;The Metamorphosis&quot; of communication with Kafka - Blexin\" \/>\n<meta property=\"og:description\" content=\"Let\u2019s discover Kafka by introducing the fundamental concepts and showing an example in .NET Core\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blexin.com\/en\/blog-en\/the-metamorphosis-of-communication-with-kafka\/\" \/>\n<meta property=\"og:site_name\" content=\"Blexin\" \/>\n<meta property=\"article:published_time\" content=\"2020-04-21T22:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-05-21T18:28:29+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/i1.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/a02436f4-6edd-4491-856a-c1985e9aa754.png?fit=1024%2C608&ssl=1\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"608\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Genny Paudice\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Genny Paudice\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/the-metamorphosis-of-communication-with-kafka\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/the-metamorphosis-of-communication-with-kafka\\\/\"},\"author\":{\"name\":\"Genny Paudice\",\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/#\\\/schema\\\/person\\\/ae0e97a3ebb79d2f73e4411c1eb28973\"},\"headline\":\"&#8220;The Metamorphosis&#8221; of communication with Kafka\",\"datePublished\":\"2020-04-21T22:00:00+00:00\",\"dateModified\":\"2021-05-21T18:28:29+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/the-metamorphosis-of-communication-with-kafka\\\/\"},\"wordCount\":1643,\"image\":{\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/the-metamorphosis-of-communication-with-kafka\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/blexin.com\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/a02436f4-6edd-4491-856a-c1985e9aa754.png?fit=1024%2C608&ssl=1\",\"keywords\":[\".NetCore\",\"Docker\",\"Kafka\",\"softwaredesign\"],\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/the-metamorphosis-of-communication-with-kafka\\\/\",\"url\":\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/the-metamorphosis-of-communication-with-kafka\\\/\",\"name\":\"\\\"The Metamorphosis\\\" of communication with Kafka - Blexin\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/the-metamorphosis-of-communication-with-kafka\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/the-metamorphosis-of-communication-with-kafka\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/blexin.com\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/a02436f4-6edd-4491-856a-c1985e9aa754.png?fit=1024%2C608&ssl=1\",\"datePublished\":\"2020-04-21T22:00:00+00:00\",\"dateModified\":\"2021-05-21T18:28:29+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/#\\\/schema\\\/person\\\/ae0e97a3ebb79d2f73e4411c1eb28973\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/the-metamorphosis-of-communication-with-kafka\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/the-metamorphosis-of-communication-with-kafka\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/the-metamorphosis-of-communication-with-kafka\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/blexin.com\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/a02436f4-6edd-4491-856a-c1985e9aa754.png?fit=1024%2C608&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/blexin.com\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/a02436f4-6edd-4491-856a-c1985e9aa754.png?fit=1024%2C608&ssl=1\",\"width\":1024,\"height\":608},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/blog-en\\\/the-metamorphosis-of-communication-with-kafka\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/blexin.com\\\/en\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"&#8220;The Metamorphosis&#8221; of communication with Kafka\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/#website\",\"url\":\"https:\\\/\\\/blexin.com\\\/en\\\/\",\"name\":\"Blexin\",\"description\":\"Con noi \u00e8 semplice\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/blexin.com\\\/en\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/blexin.com\\\/en\\\/#\\\/schema\\\/person\\\/ae0e97a3ebb79d2f73e4411c1eb28973\",\"name\":\"Genny Paudice\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3093a6ee7b7f555e94e4a5d6f19cb09f3af33635007643b2076eb89329789828?s=96&d=identicon&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3093a6ee7b7f555e94e4a5d6f19cb09f3af33635007643b2076eb89329789828?s=96&d=identicon&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3093a6ee7b7f555e94e4a5d6f19cb09f3af33635007643b2076eb89329789828?s=96&d=identicon&r=g\",\"caption\":\"Genny Paudice\"},\"url\":\"https:\\\/\\\/blexin.com\\\/en\\\/author\\\/genny-paudiceblexin-com\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\"The Metamorphosis\" of communication with Kafka - Blexin","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blexin.com\/en\/blog-en\/the-metamorphosis-of-communication-with-kafka\/","og_locale":"en_US","og_type":"article","og_title":"\"The Metamorphosis\" of communication with Kafka - Blexin","og_description":"Let\u2019s discover Kafka by introducing the fundamental concepts and showing an example in .NET Core","og_url":"https:\/\/blexin.com\/en\/blog-en\/the-metamorphosis-of-communication-with-kafka\/","og_site_name":"Blexin","article_published_time":"2020-04-21T22:00:00+00:00","article_modified_time":"2021-05-21T18:28:29+00:00","og_image":[{"width":1024,"height":608,"url":"https:\/\/i1.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/a02436f4-6edd-4491-856a-c1985e9aa754.png?fit=1024%2C608&ssl=1","type":"image\/png"}],"author":"Genny Paudice","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Genny Paudice","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/blexin.com\/en\/blog-en\/the-metamorphosis-of-communication-with-kafka\/#article","isPartOf":{"@id":"https:\/\/blexin.com\/en\/blog-en\/the-metamorphosis-of-communication-with-kafka\/"},"author":{"name":"Genny Paudice","@id":"https:\/\/blexin.com\/en\/#\/schema\/person\/ae0e97a3ebb79d2f73e4411c1eb28973"},"headline":"&#8220;The Metamorphosis&#8221; of communication with Kafka","datePublished":"2020-04-21T22:00:00+00:00","dateModified":"2021-05-21T18:28:29+00:00","mainEntityOfPage":{"@id":"https:\/\/blexin.com\/en\/blog-en\/the-metamorphosis-of-communication-with-kafka\/"},"wordCount":1643,"image":{"@id":"https:\/\/blexin.com\/en\/blog-en\/the-metamorphosis-of-communication-with-kafka\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/a02436f4-6edd-4491-856a-c1985e9aa754.png?fit=1024%2C608&ssl=1","keywords":[".NetCore","Docker","Kafka","softwaredesign"],"articleSection":["Blog"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/blexin.com\/en\/blog-en\/the-metamorphosis-of-communication-with-kafka\/","url":"https:\/\/blexin.com\/en\/blog-en\/the-metamorphosis-of-communication-with-kafka\/","name":"\"The Metamorphosis\" of communication with Kafka - Blexin","isPartOf":{"@id":"https:\/\/blexin.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/blexin.com\/en\/blog-en\/the-metamorphosis-of-communication-with-kafka\/#primaryimage"},"image":{"@id":"https:\/\/blexin.com\/en\/blog-en\/the-metamorphosis-of-communication-with-kafka\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/a02436f4-6edd-4491-856a-c1985e9aa754.png?fit=1024%2C608&ssl=1","datePublished":"2020-04-21T22:00:00+00:00","dateModified":"2021-05-21T18:28:29+00:00","author":{"@id":"https:\/\/blexin.com\/en\/#\/schema\/person\/ae0e97a3ebb79d2f73e4411c1eb28973"},"breadcrumb":{"@id":"https:\/\/blexin.com\/en\/blog-en\/the-metamorphosis-of-communication-with-kafka\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blexin.com\/en\/blog-en\/the-metamorphosis-of-communication-with-kafka\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blexin.com\/en\/blog-en\/the-metamorphosis-of-communication-with-kafka\/#primaryimage","url":"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/a02436f4-6edd-4491-856a-c1985e9aa754.png?fit=1024%2C608&ssl=1","contentUrl":"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/a02436f4-6edd-4491-856a-c1985e9aa754.png?fit=1024%2C608&ssl=1","width":1024,"height":608},{"@type":"BreadcrumbList","@id":"https:\/\/blexin.com\/en\/blog-en\/the-metamorphosis-of-communication-with-kafka\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/blexin.com\/en\/"},{"@type":"ListItem","position":2,"name":"&#8220;The Metamorphosis&#8221; of communication with Kafka"}]},{"@type":"WebSite","@id":"https:\/\/blexin.com\/en\/#website","url":"https:\/\/blexin.com\/en\/","name":"Blexin","description":"Con noi \u00e8 semplice","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blexin.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/blexin.com\/en\/#\/schema\/person\/ae0e97a3ebb79d2f73e4411c1eb28973","name":"Genny Paudice","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/3093a6ee7b7f555e94e4a5d6f19cb09f3af33635007643b2076eb89329789828?s=96&d=identicon&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/3093a6ee7b7f555e94e4a5d6f19cb09f3af33635007643b2076eb89329789828?s=96&d=identicon&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3093a6ee7b7f555e94e4a5d6f19cb09f3af33635007643b2076eb89329789828?s=96&d=identicon&r=g","caption":"Genny Paudice"},"url":"https:\/\/blexin.com\/en\/author\/genny-paudiceblexin-com\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/blexin.com\/wp-content\/uploads\/2020\/12\/a02436f4-6edd-4491-856a-c1985e9aa754.png?fit=1024%2C608&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/pcyUBx-6Yr","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/blexin.com\/en\/wp-json\/wp\/v2\/posts\/26811","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blexin.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blexin.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blexin.com\/en\/wp-json\/wp\/v2\/users\/196716251"}],"replies":[{"embeddable":true,"href":"https:\/\/blexin.com\/en\/wp-json\/wp\/v2\/comments?post=26811"}],"version-history":[{"count":10,"href":"https:\/\/blexin.com\/en\/wp-json\/wp\/v2\/posts\/26811\/revisions"}],"predecessor-version":[{"id":32929,"href":"https:\/\/blexin.com\/en\/wp-json\/wp\/v2\/posts\/26811\/revisions\/32929"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blexin.com\/en\/wp-json\/wp\/v2\/media\/26783"}],"wp:attachment":[{"href":"https:\/\/blexin.com\/en\/wp-json\/wp\/v2\/media?parent=26811"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blexin.com\/en\/wp-json\/wp\/v2\/categories?post=26811"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blexin.com\/en\/wp-json\/wp\/v2\/tags?post=26811"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}