{"id":7240,"date":"2023-10-02T21:35:08","date_gmt":"2023-10-02T20:35:08","guid":{"rendered":"https:\/\/www.baeldung.com\/apache-kafka"},"modified":"2023-10-02T21:35:08","modified_gmt":"2023-10-02T20:35:08","slug":"introduction-to-apache-kafka","status":"publish","type":"post","link":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/2023\/10\/02\/introduction-to-apache-kafka\/","title":{"rendered":"Introduction to Apache Kafka"},"content":{"rendered":"<p><img src=\"https:\/\/www.baeldung.com\/wp-content\/uploads\/2021\/09\/Java-8-Featured-1024x536.png\" class=\"webfeedsFeaturedVisual wp-post-image\" alt=\"\" decoding=\"async\" style=\"float: left; margin-right: 5px;\" loading=\"lazy\" srcset=\"https:\/\/www.baeldung.com\/wp-content\/uploads\/2021\/09\/Java-8-Featured-1024x536.png 1024w, https:\/\/www.baeldung.com\/wp-content\/uploads\/2021\/09\/Java-8-Featured-300x157.png 300w, https:\/\/www.baeldung.com\/wp-content\/uploads\/2021\/09\/Java-8-Featured-768x402.png 768w, https:\/\/www.baeldung.com\/wp-content\/uploads\/2021\/09\/Java-8-Featured-100x52.png 100w, https:\/\/www.baeldung.com\/wp-content\/uploads\/2021\/09\/Java-8-Featured.png 1200w\" sizes=\"(max-width: 580px) 100vw, 580px\" \/><\/p>\n<h2 id=\"bd-overview\" data-id=\"overview\">1. Overview<\/h2>\n<div class=\"bd-anchor\" id=\"overview\"><\/div>\n<p>In this tutorial, we&#8217;ll learn the basics of Kafka &#8211; the use cases and core concepts anyone should know. We can then find and understand <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/tag\/kafka\">more detailed articles about Kafka<\/a>.<\/p>\n<h2 id=\"bd-what-is-kafka\" data-id=\"what-is-kafka\">2. What Is Kafka?<\/h2>\n<div class=\"bd-anchor\" id=\"what-is-kafka\"><\/div>\n<p><a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/kafka.apache.org\/\">Kafka<\/a> is an open-source stream processing platform developed by the Apache Software Foundation. We can use it as a messaging system to decouple message producers and consumers, but in comparison to &#8220;classical&#8221; messaging systems like <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/activemq.apache.org\/\">ActiveMQ<\/a>, it is designed to handle real-time data streams and provides a distributed, fault-tolerant, and highly scalable architecture for processing and storing data.<\/p>\n<p>Therefore, we can use it in various use cases:<\/p>\n<ul>\n<li>Real-time data processing and analytics<\/li>\n<li>Log and event data aggregation<\/li>\n<li>Monitoring and metrics collection<\/li>\n<li>Clickstream data analysis<\/li>\n<li>Fraud detection<\/li>\n<li>Stream processing in big data pipelines<\/li>\n<\/ul>\n<h2 id=\"bd-setup-a-local-environment\" data-id=\"setup-a-local-environment\">3. Setup A Local Environment<\/h2>\n<div class=\"bd-anchor\" id=\"setup-a-local-environment\"><\/div>\n<p>If we deal with Kafka for the first time, we might like to have a local installation to experience its features. We could get this quickly with the help of Docker.<\/p>\n<h3 id=\"bd-1-install-kafka\" data-id=\"1-install-kafka\">3.1. Install Kafka<\/h3>\n<div class=\"bd-anchor\" id=\"1-install-kafka\"><\/div>\n<p>We download an <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/hub.docker.com\/r\/bashj79\/kafka-kraft\">existing image<\/a> and run a container instance with this command:<\/p>\n<pre><code class=\"language-bash\">docker run -p 9092:9092 -d bashj79\/kafka-kraft<\/code><\/pre>\n<p>This will make the so-called <em>Kafka broker<\/em> available on the host system at port 9092. Now, we would like to connect to the broker using a Kafka client. There are multiple clients that we can use.<\/p>\n<h3 id=\"bd-2-use-kafka-cli\" data-id=\"2-use-kafka-cli\">3.2. Use Kafka CLI<\/h3>\n<div class=\"bd-anchor\" id=\"2-use-kafka-cli\"><\/div>\n<p>The Kafka CLI is part of the installation and is available within the Docker container. We can use it by connecting to the container&#8217;s bash.<\/p>\n<p>First, we need to find out the container&#8217;s name with this command:<\/p>\n<pre><code class=\"language-bash\">docker ps\r\nCONTAINER ID   IMAGE                    COMMAND                  CREATED        STATUS       PORTS                    NAMES\r\n7653830053fa   bashj79\/kafka-kraft      &quot;\/bin\/start_kafka.sh&quot;    8 weeks ago    Up 2 hours   0.0.0.0:9092-&gt;9092\/tcp   awesome_aryabhata<\/code><\/pre>\n<p>In this sample, the name is <em>awesome_aryabhata<\/em>. We then <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/linux\/shell-alpine-docker\">connect to the bash<\/a> using:<\/p>\n<pre><code class=\"language-\">docker exec -it awesome_aryabhata \/bin\/bash<\/code><\/pre>\n<p>Now, we can, for example, create a topic (we&#8217;ll clarify this term later) and list all existing topics with this commands:<\/p>\n<pre><code class=\"language-bash\">cd \/opt\/kafka\/bin\r\n# create topic &#039;my-first-topic&#039;\r\nsh kafka-topics.sh --bootstrap-server localhost:9092 --create --topic my-first-topic --partitions 1 --replication-factor 1\r\n# list topics\r\nsh kafka-topics.sh --bootstrap-server localhost:9092 --list\r\n# send messages to the topic\r\nsh kafka-console-producer.sh --bootstrap-server localhost:9092 --topic my-first-topic\r\n&gt;Hello World\r\n&gt;The weather is fine\r\n&gt;I love Kafka<\/code><\/pre>\n<h3 id=\"bd-3-use-offset-explorer\" data-id=\"3-use-offset-explorer\">3.3. Use Offset Explorer<\/h3>\n<div class=\"bd-anchor\" id=\"3-use-offset-explorer\"><\/div>\n<p>The <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.kafkatool.com\/\">Offset Explorer (formerly: Kafka Tool)<\/a> is a GUI application for managing Kafka. We can <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.kafkatool.com\/download.html\">download<\/a> and install it quickly. Then, we create a connection and specify the host and port of the Kafka broker:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-175486 size-full\" src=\"https:\/\/www.baeldung.com\/wp-content\/uploads\/2023\/09\/offsetexplorer1.png\" alt=\"Screenshot of creating a connection with Offset Explorer\" width=\"782\" height=\"277\" \/><\/p>\n<p>Then, we can explore the architecture:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-175516\" src=\"https:\/\/www.baeldung.com\/wp-content\/uploads\/2023\/09\/offsetexplorer2.png\" alt=\"Kafka Architecture shown in Offset Explorer\" \/><\/p>\n<h3 id=\"bd-4-use-ui-for-apache-kafka-kafka-ui\" data-id=\"4-use-ui-for-apache-kafka-kafka-ui\">3.4. Use UI for Apache Kafka (Kafka UI)<\/h3>\n<div class=\"bd-anchor\" id=\"4-use-ui-for-apache-kafka-kafka-ui\"><\/div>\n<p>The <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/github.com\/provectus\/kafka-ui\">UI for Apache Kafka (Kafka UI)<\/a> is a web UI, implemented with Spring Boot and React, and provided as a Docker container <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/docs.kafka-ui.provectus.io\/overview\/getting-started\">for a simple installation<\/a> with the following command:<\/p>\n<pre><code class=\"language-bash\">docker run -it -p 8080:8080 -e DYNAMIC_CONFIG_ENABLED=true provectuslabs\/kafka-ui<\/code><\/pre>\n<p>We can then open the UI in the browser using <a href=\"http:\/\/localhost:8080\/\">http:\/\/localhost:8080<\/a> and define a cluster, as this picture shows:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-175523 size-full\" src=\"https:\/\/www.baeldung.com\/wp-content\/uploads\/2023\/09\/kafka-ui.png\" alt=\"Screenshot from Kafka UI\" width=\"902\" height=\"799\" \/><\/p>\n<p>Because the Kafka broker runs in a different container than the Kafka UI&#8217;s backend, it will not have access to <em>localhost:9092<\/em>. We could instead address the host system using <em>host.docker.internal:9092<\/em>, but this is just the bootstrapping URL.<\/p>\n<p>Unfortunately, Kafka itself will return a response that leads to a redirection to localhost:9092 again, which won&#8217;t work. If we do not want to configure Kafka (because this would break with the other clients then), we need to create a port forwarding from the Kafka UI&#8217;s container port 9092 to the host systems port 9092. The following sketch illustrates the connections:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-175531 size-full\" src=\"https:\/\/www.baeldung.com\/wp-content\/uploads\/2023\/09\/kafka-ui-port-forwarding.png\" alt=\"Sketch showing Kafka UI Port Forwarding\" width=\"1000\" height=\"540\" \/><\/p>\n<p>We can setup this container-internal port forwarding, e.g. using <em>socat<\/em>. We have to install it within the container (Alpine Linux), so we need to connect to the container&#8217;s bash with root permissions. So we need these commands, beginning within the host system&#8217;s command line:<\/p>\n<pre><code class=\"language-bash\"># Connect to the container&#039;s bash (find out the name with &#039;docker ps&#039;)\r\ndocker exec -it --user=root &lt;name-of-kafka-ui-container&gt; \/bin\/sh\r\n# Now, we are connected to the container&#039;s bash.\r\n# Let&#039;s install &#039;socat&#039;\r\napk add socat\r\n# Use socat to create the port forwarding\r\nsocat tcp-listen:9092,fork tcp:host.docker.internal:9092\r\n# This will lead to a running process that we don&#039;t kill as long as the container&#039;s running<\/code><\/pre>\n<p>Unfortunately, we need to run <em>socat<\/em> each time we start the container. Another possibility would be to provide an extension to the <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/github.com\/provectus\/kafka-ui\/blob\/master\/kafka-ui-api\/Dockerfile\">Dockerfile<\/a>.<\/p>\n<p>Now, we can specify localhost:9092 as the bootstrap server within the Kafka UI and should be able to view and create topics, as shown below:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-175535 size-full\" src=\"https:\/\/www.baeldung.com\/wp-content\/uploads\/2023\/09\/kafka-ui-topics-1.png\" alt=\"Topics displayed by Kafka UI\" width=\"1057\" height=\"370\" \/><\/p>\n<h3 id=\"bd-5-use-kafka-java-client\" data-id=\"5-use-kafka-java-client\">3.5. Use Kafka Java Client<\/h3>\n<div class=\"bd-anchor\" id=\"5-use-kafka-java-client\"><\/div>\n<p>We have to add <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/mvnrepository.com\/artifact\/org.apache.kafka\/kafka-clients\">the following Maven dependency<\/a> to our project:<\/p>\n<pre><code class=\"language-xml\">&lt;dependency&gt;\r\n    &lt;groupId&gt;org.apache.kafka&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;kafka-clients&lt;\/artifactId&gt;\r\n    &lt;version&gt;3.5.1&lt;\/version&gt;\r\n&lt;\/dependency&gt;<\/code><\/pre>\n<p>We can then connect to Kafka and consume the messages we produced before:<\/p>\n<pre><code class=\"language-java\">\/\/ specify connection properties\r\nProperties props = new Properties();\r\nprops.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, &quot;localhost:9092&quot;);\r\nprops.put(ConsumerConfig.GROUP_ID_CONFIG, &quot;MyFirstConsumer&quot;);\r\nprops.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());\r\nprops.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());\r\n\/\/ receive messages that were sent before the consumer started\r\nprops.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, &quot;earliest&quot;);\r\n\/\/ create the consumer using props.\r\ntry (final Consumer&lt;Long, String&gt; consumer = new KafkaConsumer&lt;&gt;(props)) {\r\n    \/\/ subscribe to the topic.\r\n    final String topic = &quot;my-first-topic&quot;;\r\n    consumer.subscribe(Arrays.asList(topic));\r\n    \/\/ poll messages from the topic and print them to the console\r\n    consumer\r\n      .poll(Duration.ofMinutes(1))\r\n      .forEach(System.out::println);\r\n}<\/code><\/pre>\n<p>Of course, there is an integration for the <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/spring-kafka\">Kafka Client in Spring<\/a>.<\/p>\n<h2 id=\"bd-basic-concept\" data-id=\"basic-concept\">4. Basic Concept<\/h2>\n<div class=\"bd-anchor\" id=\"basic-concept\"><\/div>\n<h3 id=\"bd-1-producers-amp-consumers\" data-id=\"1-producers-amp-consumers\">4.1. Producers &amp; Consumers<\/h3>\n<div class=\"bd-anchor\" id=\"1-producers-amp-consumers\"><\/div>\n<p><strong>We can differentiate Kafka clients into consumers and producers.<\/strong> Producers send messages to Kafka, while consumers receive messages from Kafka. They only receive messages by actively polling from Kafka. Kafka itself is acting in a passive way. This allows each consumer to have its own performance without blocking Kafka.<\/p>\n<p>Of course, there can be multiple producers and multiple consumers at the same time. And, of course, one application can contain both producers and consumers.<\/p>\n<p>Consumers are part of a <em>Consumer Group<\/em> that Kafka identifies by a simple name. <strong>Only one consumer of a consumer group will receive the message.<\/strong> This allows scaling out consumers with the guarantee of only-once message delivery.<\/p>\n<p>The following picture shows multiple producers and consumers working together with Kafka:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-175581 size-full\" src=\"https:\/\/www.baeldung.com\/wp-content\/uploads\/2023\/09\/concepts-01-consumers-producers.png\" alt=\"Producers and Consumers\" width=\"580\" height=\"480\" \/><\/p>\n<h3 id=\"bd-2-messages\" data-id=\"2-messages\">4.2. Messages<\/h3>\n<div class=\"bd-anchor\" id=\"2-messages\"><\/div>\n<p>A message (we can also name it &#8220;<em>record<\/em>&#8221; or &#8220;<em>event<\/em>&#8220;, depending on the use case) is the fundamental unit of data that Kafka processes. Its payload can be of any binary format as well as text formats like plain text, <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/avro.apache.org\/\">Avro<\/a>, XML, or JSON.<\/p>\n<p>Each producer has to specify a serializer to transform the message object into the binary payload format. Each consumer has to specify a corresponding deserializer to transform the payload format back to an object within its JVM. We call these components shortly <em>SerDes<\/em>. There are <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/kafka.apache.org\/documentation\/streams\/developer-guide\/datatypes.html\">built-in SerDes<\/a>, but we can implement custom SerDes too.<\/p>\n<p>The following picture shows the payload serialization and deserialization process:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-176186\" src=\"https:\/\/www.baeldung.com\/wp-content\/uploads\/2023\/09\/concepts-02-records.png\" alt=\"Payload SerDes Process\" \/><\/p>\n<p>Additionally, a message can have the following optional attributes:<\/p>\n<ul>\n<li>A key that also can be of any binary format. If we use keys, we also need SerDes. Kafka uses keys for partitioning (we&#8217;ll discuss this in more detail in the next chapter).<\/li>\n<li>A timestamp indicates when the message was produced. Kafka uses timestamps for ordering messages or to implement retention policies.<\/li>\n<li>We can <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/java-kafka-custom-headers\">apply headers<\/a> to associate metadata with the payload. E.g. <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/spring-kafka\">Spring<\/a> adds by default type headers for serialization and deserialization.<\/li>\n<\/ul>\n<h3 id=\"bd-3-topics-amp-partitions\" data-id=\"3-topics-amp-partitions\">4.3. Topics &amp; Partitions<\/h3>\n<div class=\"bd-anchor\" id=\"3-topics-amp-partitions\"><\/div>\n<p><strong>A topic is a logical channel or category to which producers publish messages.<\/strong> Consumers subscribe to a topic to receive messages from in the context of their consumer group.<\/p>\n<p>By default, the retention policy of a topic is 7 days, i.e. after 7 days, Kafka deletes the messages automatically, independent of delivering to consumers or not. We can <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/kafka-message-retention\">configure this<\/a> if necessary.<\/p>\n<p><strong>Topics consist of partitions (at least one).<\/strong> To be exact, messages are stored in one partition of the topic. Within one partition, messages get an order number (<em>offset<\/em>). This can ensure that messages are delivered to the consumer in the same order as they were stored in the partition. And, by storing the offsets that a consumer group already received, Kafka guarantees only-once delivery.<\/p>\n<p>By dealing with multiple partitions, we can determine that <strong>Kafka can provide both ordering guarantees and load balancing over a pool of consumer processes.<\/strong><\/p>\n<p><strong>One consumer will be assigned to one partition when it subscribes to the topic<\/strong>, e.g. with the Java Kafka client API, as we have already seen:<\/p>\n<pre><code class=\"language-java\">String topic = &quot;my-first-topic&quot;;\r\nconsumer.subscribe(Arrays.asList(topic));<\/code><\/pre>\n<p>However, for a consumer, it is possible to choose the partition(s) it wants to poll messages from:<\/p>\n<pre><code class=\"language-\">TopicPartition myPartition = new TopicPartition(topic, 1);\r\nconsumer.assign(Arrays.asList(myPartition));\r\n<\/code><\/pre>\n<p>The disadvantage of this variant is that all group consumers have to use this, so automatically assigning partitions to group consumers won&#8217;t work in combination with single consumers that connect to a special partition. Also, rebalancing is not possible in case of architectural changes like adding further consumers to the group.<\/p>\n<p><strong>Ideally, we have as many consumers as partitions<\/strong>, so that every consumer can be assigned to exactly one of the partitions, as shown below:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-176297\" src=\"https:\/\/www.baeldung.com\/wp-content\/uploads\/2023\/09\/concepts-03-partitions-1.png\" alt=\"ideal count of consumers\" \/><\/p>\n<p>If we have more consumers than partitions, those consumers won&#8217;t receive messages from any partition:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-176298\" src=\"https:\/\/www.baeldung.com\/wp-content\/uploads\/2023\/09\/concepts-03-partitions-2.png\" alt=\"too much consumers\" \/><\/p>\n<p>If we have fewer consumers than partitions, consumers will receive messages from multiple partitions, which conflicts with optimal load balancing:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-176299\" src=\"https:\/\/www.baeldung.com\/wp-content\/uploads\/2023\/09\/concepts-03-partitions-3.png\" alt=\"too less consumers\" \/><\/p>\n<p><strong>Producers do not necessarily send messages to only one partition.<\/strong> Every produced message is assigned to one partition automatically, following these rules:<\/p>\n<ul>\n<li>Producers can specify a partition as part of the message. If done so, this has the highest priority<\/li>\n<li>If the message has a key, partitioning is done by calculating the hash of the key. Keys with the same hash will be stored in the same partition. Ideally, we have at least as many hashes as partitions<\/li>\n<li>Otherwise, the <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/cwiki.apache.org\/confluence\/display\/KAFKA\/KIP-480%3A+Sticky+Partitioner\"><em>Sticky Partitioner<\/em><\/a> distributes the messages to partitions<\/li>\n<\/ul>\n<p><strong>Again, storing messages to the same partition will retain the message ordering, while storing messages to different partitions will lead to disordering but parallel processing.<\/strong><\/p>\n<p>If the default partitioning does not match our expectations, we can simply implement a custom partitioner. Therefore, we implement the <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/kafka.apache.org\/34\/javadoc\/org\/apache\/kafka\/clients\/producer\/Partitioner.html\">Partitioner<\/a> interface and register it during the initialization of the producer:<\/p>\n<pre><code class=\"language-\">Properties producerProperties = new Properties();\r\n\/\/ ...  \r\nproducerProperties.put(ProducerConfig.PARTITIONER_CLASS_CONFIG, MyCustomPartitioner.class.getName());\r\nKafkaProducer&lt;String, String&gt; producer = new KafkaProducer&lt;&gt;(producerProperties);<\/code><\/pre>\n<p>The following picture shows producers and consumers and their connections to the partitions:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-176327\" src=\"https:\/\/www.baeldung.com\/wp-content\/uploads\/2023\/09\/concepts-03-partitions-4.png\" alt=\"producers and partitioners\" \/><\/p>\n<p>Each producer has its own partitioner, so if we want to ensure that messages are partitioned consistently within the topic, we have to ensure that the partitioners of all producers work the same way, or we should only work with a single producer.<\/p>\n<p>Partitions store messages in the order they arrive at the Kafka broker. Typically, a producer does not send each message as a single request, but it will send multiple messages within a batch. If we need to ensure the order of the messages and only-once delivery within one partition, we need <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/kafka-exactly-once\">transaction-aware producers and consumers<\/a>.<\/p>\n<h3 id=\"bd-4-clusters-and-partition-replicas\" data-id=\"4-clusters-and-partition-replicas\">4.4. Clusters and Partition Replicas<\/h3>\n<div class=\"bd-anchor\" id=\"4-clusters-and-partition-replicas\"><\/div>\n<p>As we have found out, Kafka uses topic partitions to allow parallel message delivery and load balancing of consumers. But Kafka itself must be scalable and fault-tolerant. <strong>So we typically do not use a single Kafka Broker, but a <em>Cluster<\/em> of multiple brokers.<\/strong> These brokers do not behave completely the same, but each of them is assigned special tasks that the rest of the cluster can then absorb if one broker fails.<\/p>\n<p>To understand this, we need to expand our understanding of topics. When creating a topic, we not only specify the number of partitions but also the number of brokers that jointly manage the partitions using synchronization. We call this the <em>Replication Factor<\/em>. For example, using the Kafka CLI, we could create a topic with 6 partitions, each of them synchronized on 3 brokers:<\/p>\n<pre><code class=\"language-bash\">sh kafka-topics.sh --bootstrap-server localhost:9092 --create --topic my-replicated-topic --partitions 6 --replication-factor 3<\/code><\/pre>\n<p>For example, a replication factor of three means, that the cluster is resilient for up to two replica failures (<em>N-1 resiliency<\/em>). <strong>We have to ensure that we have at least as many brokers as we specify as the replication factor.<\/strong> Otherwise, Kafka does not create the topic until the count of brokers increases.<\/p>\n<p><strong>For better efficiency, replication of a partition only occurs in one direction.<\/strong> Kafka achieves this by declaring one of the brokers as the <em>Partition Leader<\/em>. Producers only send messages to the partition leader, and the leader then synchronizes with the other brokers. Consumers will also poll from the partition leader because the increasing consumer group&#8217;s offset has to be synchronized too.<\/p>\n<p><strong>Partition leading is distributed to multiple brokers.<\/strong> Kafka tries to find different brokers for different partitions. Let&#8217;s see an example with four brokers and two partitions with a replication factor of three:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-169748\" src=\"https:\/\/www.baeldung.com\/wp-content\/uploads\/2023\/09\/kafka-topology-1024x549.png\" alt=\"Image displaying Kafka Topology with 2 partitions and a replication factor of 2\" width=\"580\" height=\"311\" \/><\/p>\n<p>Broker 1 is the leader of Partition 1, and Broker 4 is the leader of Partition 2. So each client will connect to those brokers when sending or polling messages from these partitions. To get information about the partition leaders and other available brokers (metadata), there is a special bootstrapping mechanism. In summary, we can say that every broker can provide the cluster&#8217;s metadata, so the client could initialize the connection with each of these brokers, and will redirect to the partition leaders then. That&#8217;s why we can specify multiple brokers as <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/java-kafka-bootstrap-server\">bootstrapping servers<\/a>.<\/p>\n<p>If one partition-leading broker fails, Kafka will declare one of the still-working brokers as the new partition leader. Then, all clients have to connect to the new leader. In our example, if Broker 1 fails, Broker 2 becomes the new leader of Partition 1. Then, the clients that were connected to Broker 1 have to switch to Broker 2.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-169754 size-large\" src=\"https:\/\/www.baeldung.com\/wp-content\/uploads\/2023\/09\/kafka-topology-failure-1024x581.png\" alt=\"Kafka Topology after Broker Failure\" width=\"580\" height=\"329\" \/><\/p>\n<p>Kafka uses <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/kafka-shift-from-zookeeper-to-kraft\">Kraft (in earlier versions: Zookeeper)<\/a> for the orchestration of all brokers within the cluster.<\/p>\n<h3 id=\"bd-4-putting-all-together\" data-id=\"4-putting-all-together\">4.4. Putting All Together<\/h3>\n<div class=\"bd-anchor\" id=\"4-putting-all-together\"><\/div>\n<p>If we put producers and consumers together with a cluster of three brokers that manage a single topic with three partitions and a replication factor of 3, we&#8217;ll get this architecture:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-large wp-image-176482\" src=\"https:\/\/www.baeldung.com\/wp-content\/uploads\/2023\/09\/kafta-topology-1024x408.png\" alt=\"Topics, Partitions and Replicas\" \/><\/p>\n<h2 id=\"bd-ecosystem\" data-id=\"ecosystem\">5. Ecosystem<\/h2>\n<div class=\"bd-anchor\" id=\"ecosystem\"><\/div>\n<p>We already know that multiple clients like a CLI, a Java-based client with integration to Spring applications, and multiple GUI tools are available to connect with Kafka. Of course, there are further Client APIs for other programming languages (e.g., <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/docs.confluent.io\/platform\/current\/clients\/librdkafka\/html\/md_INTRODUCTION.html\">C\/C++<\/a>, <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/github.com\/confluentinc\/confluent-kafka-python\">Python<\/a>, or <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/kafka.js.org\/\">Javascript<\/a>), but those are not part of the Kafka project.<\/p>\n<p>Built on top of these APIs, there are further APIs for special purposes.<\/p>\n<h3 id=\"bd-1-kafka-connect-api\" data-id=\"1-kafka-connect-api\">5.1. Kafka Connect API<\/h3>\n<div class=\"bd-anchor\" id=\"1-kafka-connect-api\"><\/div>\n<p><a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/kafka-connectors-guide\">Kafka Connect<\/a> is an API for exchanging data with third-party systems. There are <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/docs.confluent.io\/platform\/current\/connect\/kafka_connectors.html\">existing connectors<\/a> e.g. for AWS S3, JDBC, or even for exchanging data between different Kafka clusters. And of course, we can write custom connectors too.<\/p>\n<h3 id=\"bd-2-kafka-streams-api\" data-id=\"2-kafka-streams-api\">5.2. Kafka Streams API<\/h3>\n<div class=\"bd-anchor\" id=\"2-kafka-streams-api\"><\/div>\n<p><a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/java-kafka-streams\">Kafka Streams<\/a> is an API for implementing stream processing applications that get their input from a Kafka topic, and store the result in another Kafka topic.<\/p>\n<h3 id=\"bd-3-ksql\" data-id=\"3-ksql\">5.3. KSQL<\/h3>\n<div class=\"bd-anchor\" id=\"3-ksql\"><\/div>\n<p>KSQL is an SQL-like interface built on top of Kafka Streams. It does not require us to develop Java code, but we can declare SQL-like syntax to define stream processing of messages that are exchanged with Kafka. For this, we use the <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/ksqldb\">ksqlDB<\/a>, which connects to the Kafka cluster. We can access ksqlDB with a CLI or with a Java client application.<\/p>\n<h3 id=\"bd-4-kafka-rest-proxy\" data-id=\"4-kafka-rest-proxy\">5.4. Kafka REST Proxy<\/h3>\n<div class=\"bd-anchor\" id=\"4-kafka-rest-proxy\"><\/div>\n<p>The <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/github.com\/confluentinc\/kafka-rest\">Kafka REST proxy<\/a> provides a RESTful interface to a Kafka cluster. This way, we do not need any Kafka clients and avoid using the native Kafka protocol. It allows web frontends to connect with Kafka and makes it possible to use network components like API gateways or firewalls.<\/p>\n<h3 id=\"bd-5-kafka-operators-for-kubernetes-strimzi\" data-id=\"5-kafka-operators-for-kubernetes-strimzi\">5.5. Kafka Operators for Kubernetes (Strimzi)<\/h3>\n<div class=\"bd-anchor\" id=\"5-kafka-operators-for-kubernetes-strimzi\"><\/div>\n<p><a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/strimzi.io\/\">Strimzi<\/a> is an open-source project that provides a way to run Kafka on Kubernetes and OpenShift platforms. It introduces custom Kubernetes resources making it easier to declare and manage Kafka-related resources in a Kubernetes-native way. It follows the <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/kubernetes.io\/docs\/concepts\/extend-kubernetes\/operator\/\">Operator Pattern<\/a>, i.e. operators automate tasks like provisioning, scaling, rolling updates, and monitoring of Kafka clusters.<\/p>\n<h2 id=\"bd-conclusion\" data-id=\"conclusion\">6. Conclusion<\/h2>\n<div class=\"bd-anchor\" id=\"conclusion\"><\/div>\n<p>In this article, we have learned that Kafka is designed for high scalability and fault tolerance. Producers collect messages and send them in batches, topics are divided into partitions to allow parallel message delivery and load balancing of consumers, and replication is done over multiple brokers to ensure fault tolerance.<\/p>\n<p>As usual, all the code implementations are available\u00a0<a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/github.com\/eugenp\/tutorials\/tree\/master\/apache-kafka-2\">over on GitHub<\/a>.<\/p>\n<p><Img align=\"left\" border=\"0\" height=\"1\" width=\"1\" alt=\"\" style=\"border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;\" hspace=\"0\" src=\"https:\/\/feeds.feedblitz.com\/~\/i\/797161529\/0\/baeldung\"><\/p>\n<div style=\"clear:both;padding-top:0.2em;\"><a title=\"Like on Facebook\" href=\"https:\/\/feeds.feedblitz.com\/_\/28\/797161529\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/fblike20.png\" style=\"border:0;margin:0;padding:0;\"><\/a>&#160;<a title=\"Pin it!\" href=\"https:\/\/feeds.feedblitz.com\/_\/29\/797161529\/baeldung,https%3A%2F%2Fwww.baeldung.com%2Fwp-content%2Fuploads%2F2021%2F09%2FJava-8-Featured-1024x536.png\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/pinterest20.png\" style=\"border:0;margin:0;padding:0;\"><\/a>&#160;<a title=\"Tweet This\" href=\"https:\/\/feeds.feedblitz.com\/_\/24\/797161529\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/twitter20.png\" style=\"border:0;margin:0;padding:0;\"><\/a>&#160;<a title=\"Subscribe by email\" href=\"https:\/\/feeds.feedblitz.com\/_\/19\/797161529\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/email20.png\" style=\"border:0;margin:0;padding:0;\"><\/a>&#160;<a title=\"Subscribe by RSS\" href=\"https:\/\/feeds.feedblitz.com\/_\/20\/797161529\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/rss20.png\" style=\"border:0;margin:0;padding:0;\"><\/a>&#160;<a rel=\"NOFOLLOW\" title=\"View Comments\" href=\"https:\/\/www.baeldung.com\/apache-kafka#respond\"><img decoding=\"async\" height=\"20\" style=\"border:0;margin:0;padding:0;\" src=\"https:\/\/assets.feedblitz.com\/i\/comments20.png\"><\/a>&#160;<a title=\"Follow Comments via RSS\" href=\"https:\/\/www.baeldung.com\/apache-kafka\/feed\"><img decoding=\"async\" height=\"20\" style=\"border:0;margin:0;padding:0;\" src=\"https:\/\/assets.feedblitz.com\/i\/commentsrss20.png\"><\/a><\/p>\n<h3 style=\"clear:left;padding-top:10px\">Related Stories<\/h3>\n<ul>\n<li><a rel=\"NOFOLLOW\" href=\"https:\/\/www.baeldung.com\/apache-kafka-check-server-is-running\">Guide to Check if Apache Kafka Server Is Running<\/a><\/li>\n<\/ul>\n<p>&#160;<\/p><\/div>\n\n<h2><b>Commercials Cooperation Advertisements:<\/b><\/h2>\r\n<p><br>(1) IT Teacher IT Freelance<br> <\/p>\r\n<a href=https:\/\/itteacheritfreelance.hk\/wordpress><img src=http:\/\/gamefootballmobileanimeiphone.com\/wp-content\/uploads\/2023\/09\/ITTeacherITFreelance-Website.png alt=IT\u96fb\u8166\u88dc\u7fd2 java\u88dc\u7fd2 \u70ba\u5927\u5bb6\u914d\u5c0d\u96fb\u8166\u88dc\u7fd2,IT freelance, \u79c1\u4eba\u8001\u5e2b, PHP\u88dc\u7fd2,CSS\u88dc\u7fd2,XML,Java\u88dc\u7fd2,MySQL\u88dc\u7fd2,graphic design\u88dc\u7fd2,\u4e2d\u5c0f\u5b78ICT\u88dc\u7fd2,\u4e00\u5c0d\u4e00\u79c1\u4eba\u88dc\u7fd2\u548cFreelance\u81ea\u7531\u5de5\u4f5c\u914d\u5c0d\u3002\/><\/a><p><a href=https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/findteacher>\u7acb\u523b\u8a3b\u518a\u53ca\u5831\u540d\u96fb\u8166\u88dc\u7fd2\u8ab2\u7a0b\u5427! <\/a><br>\r\n\r\n\u7535\u5b50\u8ba1\u7b97\u673a -\u6559\u80b2 -IT \u96fb\u8166\u73ed\u201d ( IT\u96fb\u8166\u88dc\u7fd2 ) \u63d0\u4f9b\u4e00\u500b\u65b9\u4fbf\u7684\u7535\u5b50\u8ba1\u7b97\u673a \u6559\u80b2\u5e73\u53f0, \u70ba\u5927\u5bb6\u914d\u5c0d\u4fe1\u606f\u6280\u672f, \u96fb\u8166 \u8001\u5e2b, IT freelance \u548c programming expert. \u8b93\u5927\u5bb6\u65b9\u4fbf\u5730\u5c31\u80fd\u627e\u5230\u5408\u9069\u7684\u96fb\u8166\u88dc\u7fd2, \u96fb\u8166\u73ed, \u5bb6\u6559, \u79c1\u4eba\u8001\u5e2b.  <br>\r\n\r\nWe are a education and information platform which you can find a IT private tutorial teacher or freelance. <br>\r\n\r\nAlso we provide different information about information technology, Computer, programming, mobile, Android, apple, game, movie, anime, animation\u2026 \r\n<\/p>\n<p><br>(2) ITSec<br> <\/p><a href=https:\/\/itsec.vip><img src=http:\/\/gamefootballmobileanimeiphone.com\/wp-content\/uploads\/2023\/09\/ITSec-Main-Promotion-Image.png alt= https:\/\/itsec.vip\/\r\nSecure Your Computers from Cyber Threats and mitigate risks with professional services to defend Hackers.  \r\nITSec provide IT Security and Compliance Services, including IT Compliance Services, Risk Assessment, IT Audit, Security Assessment and Audit, ISO 27001 Consulting and Certification, GDPR Compliance Services, Privacy Impact Assessment (PIA), Penetration test, Ethical Hacking, Vulnerabilities scan, IT Consulting, Data Privacy Consulting, Data Protection Services, Information Security Consulting, Cyber Security Consulting, Network Security Audit, Security Awareness Training.\/><\/a> \r\n<br><br> \r\n<p><a href=https:\/\/itsec.vip>www.ITSec.vip<\/a> <br> <br> \r\n<p><a href=https:\/\/sraa.com.hk>www.Sraa.com.hk<\/a> <br> <br> \r\n<p><a href=https:\/\/itsec.hk>www.ITSec.hk<\/a> <br> <br> \r\n<p><a href=https:\/\/penetrationtest.hk>www.Penetrationtest.hk<\/a> <br> <br> \r\n<p><a href=https:\/\/itseceu.uk>www.ITSeceu.uk<\/a> <br> <br> \r\nSecure Your Computers from Cyber Threats and mitigate risks with professional services to defend Hackers. <br><br>\r\nITSec provide IT Security and Compliance Services, including IT Compliance Services, Risk Assessment, IT Audit, Security Assessment and Audit, ISO 27001 Consulting and Certification, GDPR Compliance Services, Privacy Impact Assessment (PIA), Penetration test, Ethical Hacking, Vulnerabilities scan, IT Consulting, Data Privacy Consulting, Data Protection Services, Information Security Consulting, Cyber Security Consulting, Network Security Audit, Security Awareness Training. \r\n<br><br>Contact us right away. <br><br>Email (Prefer using email to contact us): <br>SalesExecutive@ITSec.vip<\/p>","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/www.baeldung.com\/wp-content\/uploads\/2021\/09\/Java-8-Featured-1024x536.png\" class=\"webfeedsFeaturedVisual wp-post-image\" alt=\"\" loading=\"lazy\"><\/p>\n<p>Learn the the basics of Apache Kafka.<\/p>\n<div><a title=\"Like on Facebook\" href=\"https:\/\/feeds.feedblitz.com\/_\/28\/797161529\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/fblike20.png\"><\/a>\u00a0<a title=\"Pin it!\" href=\"https:\/\/feeds.feedblitz.com\/_\/29\/797161529\/baeldung,https%3A%2F%2Fwww.baeldung.com%2Fwp-content%2Fuploads%2F2021%2F09%2FJava-8-Featured-1024x536.png\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/pinterest20.png\"><\/a>\u00a0<a title=\"Tweet This\" href=\"https:\/\/feeds.feedblitz.com\/_\/24\/797161529\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/twitter20.png\"><\/a>\u00a0<a title=\"Subscribe by email\" href=\"https:\/\/feeds.feedblitz.com\/_\/19\/797161529\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/email20.png\"><\/a>\u00a0<a title=\"Subscribe by RSS\" href=\"https:\/\/feeds.feedblitz.com\/_\/20\/797161529\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/rss20.png\"><\/a>\u00a0<a rel=\"NOFOLLOW\" title=\"View Comments\" href=\"https:\/\/www.baeldung.com\/apache-kafka#respond\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/comments20.png\"><\/a>\u00a0<a title=\"Follow Comments via RSS\" href=\"https:\/\/www.baeldung.com\/apache-kafka\/feed\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/commentsrss20.png\"><\/a><\/p>\n<h3>Related Stories<\/h3>\n<ul>\n<li><a rel=\"NOFOLLOW\" href=\"https:\/\/www.baeldung.com\/apache-kafka-check-server-is-running\">Guide to Check if Apache Kafka Server Is Running<\/a><\/li>\n<\/ul>\n<p>\u00a0<\/p><\/div>\n","protected":false},"author":292,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"site-container-style":"default","site-container-layout":"default","site-sidebar-layout":"default","disable-article-header":"default","disable-site-header":"default","disable-site-footer":"default","disable-content-area-spacing":"default","footnotes":""},"categories":[22],"tags":[61,122,127,129,124,128,125,132,131,133,126,130,123,66,94,88,97,56,64,65,60,2860,112,40,75,95,104,33,120,105,101,98,115,30,29,41,86,70,69,68,72,71,26,118,108,87,46,55,48,52,54,51,50,83,62,58,57,2861,109,35,59,63,85,79,82,96,80,27,81,114,44,42,43,45,38,39,110,117,100,111,116,73,89,90,92,91,93,84,78,37,102,34,36,77,67,74,99,113,119,28,121,32,47,49,53,103,31,76],"class_list":["post-7240","post","type-post","status-publish","format-standard","hentry","category-mobile","tag-airpods","tag-anime","tag-anime-characters","tag-anime-cosplay","tag-anime-edits","tag-anime-merchandise","tag-anime-movies","tag-anime-news","tag-anime-recommendations","tag-anime-reviews","tag-anime-series","tag-anime-streaming","tag-animes","tag-app-store","tag-app-store-samsung","tag-appgallery","tag-appgallery-oneplus","tag-apple","tag-apple-music","tag-apple-tv","tag-apple-watch","tag-architecture","tag-bbc-sport","tag-best-mobile-games","tag-bixby","tag-bixby-xiaomi","tag-champions-league","tag-cyberpunk","tag-cyberpunk-2077","tag-fantasy-football","tag-fifa","tag-football","tag-formula-1","tag-fortnite","tag-free-fire","tag-free-mobile-games","tag-freebuds-pro","tag-galaxy-a52","tag-galaxy-note-20","tag-galaxy-s21","tag-galaxy-watch-4","tag-galaxy-z-fold-3","tag-game","tag-games","tag-golf","tag-harmonyos","tag-how-to-backup-iphone","tag-how-to-factory-reset-iphone","tag-how-to-reset-iphone","tag-how-to-restore-iphone","tag-how-to-unlock-iphone","tag-how-to-unlock-iphone-5","tag-how-to-unlock-iphone-6","tag-huawei","tag-ios","tag-ipad","tag-iphone","tag-kafka","tag-live-soccer","tag-lol","tag-macbook","tag-macos","tag-mate-40-pro","tag-mi-11-lite","tag-mi-home-security-camera-basic-1080p","tag-mi-home-security-camera-basic-1080p-huawei","tag-mi-smart-band-6","tag-minecraft","tag-miui","tag-mlb-scores","tag-mobile-game-design","tag-mobile-game-development","tag-mobile-game-marketing","tag-mobile-game-monetization","tag-mobile-games","tag-mobile-gaming","tag-nba-scores","tag-nba-standings","tag-nfl","tag-nfl-scores","tag-nhl-scores","tag-one-ui","tag-oneplus","tag-oneplus-9-pro","tag-oneplus-buds-pro","tag-oneplus-nord-ce-5g","tag-oxygenos","tag-p40-pro-plus","tag-poco-x3-pro","tag-pokemon","tag-premier-league","tag-pubg","tag-pubg-mobile","tag-redmi-note-10-pro","tag-samsung","tag-samsung-pay","tag-soccer","tag-sports","tag-steam","tag-steeam","tag-top-10-anime","tag-valorant","tag-when-do-the-iphone-7-come-out","tag-when-does-the-iphone-7-come-out","tag-when-is-the-iphone-7-coming-out","tag-world-cup","tag-xbox-series-x","tag-xiaomi"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/posts\/7240","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/users\/292"}],"replies":[{"embeddable":true,"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/comments?post=7240"}],"version-history":[{"count":1,"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/posts\/7240\/revisions"}],"predecessor-version":[{"id":7241,"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/posts\/7240\/revisions\/7241"}],"wp:attachment":[{"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/media?parent=7240"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/categories?post=7240"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/tags?post=7240"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}