{"id":52,"date":"2023-12-02T11:09:00","date_gmt":"2023-12-02T16:09:00","guid":{"rendered":"https:\/\/coding101.xyz\/?p=52"},"modified":"2023-12-02T19:57:53","modified_gmt":"2023-12-03T00:57:53","slug":"kafka-primer","status":"publish","type":"post","link":"https:\/\/coding101.xyz\/?p=52","title":{"rendered":"Kafka Primer"},"content":{"rendered":"\n<p>This is a short article about how to setup a Kafka application up and running. <\/p>\n\n\n\n<!--more-->\n\n\n\n<p>Kafka is a messaging service, very fast. It revolves around topics of messages. Messages have a key and a payload. Typically the server listens to port 9092 TCP<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Maven<\/h2>\n\n\n\n<p>The following packages are needed. The client one covers producer and consumer, the streams covers streams. Look it up for the latest version. <\/p>\n\n\n\n<!-- HTML generated using hilite.me --><div style=\"background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;\"><pre style=\"margin: 0; line-height: 125%\"><span style=\"color: #333333\">&lt;<\/span>dependencies<span style=\"color: #333333\">&gt;<\/span>\n<span style=\"color: #333333\">&lt;<\/span>dependency<span style=\"color: #333333\">&gt;<\/span>\n<span style=\"color: #333333\">&lt;<\/span>groupId<span style=\"color: #333333\">&gt;<\/span>org<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">apache<\/span><span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">kafka<\/span><span style=\"color: #333333\">&lt;\/<\/span>groupId<span style=\"color: #333333\">&gt;<\/span>\n<span style=\"color: #333333\">&lt;<\/span>artifactId<span style=\"color: #333333\">&gt;<\/span>kafka<span style=\"color: #333333\">-<\/span>clients<span style=\"color: #333333\">&lt;\/<\/span>artifactId<span style=\"color: #333333\">&gt;<\/span>\n<span style=\"color: #333333\">&lt;<\/span>version<span style=\"color: #333333\">&gt;<\/span><span style=\"color: #6600EE; font-weight: bold\">3.6<\/span><span style=\"color: #333333\">.<\/span><span style=\"color: #0000DD; font-weight: bold\">0<\/span><span style=\"color: #333333\">&lt;\/<\/span>version<span style=\"color: #333333\">&gt;<\/span>\n<span style=\"color: #333333\">&lt;\/<\/span>dependency<span style=\"color: #333333\">&gt;<\/span>\n<span style=\"color: #333333\">&lt;<\/span>dependency<span style=\"color: #333333\">&gt;<\/span>\n<span style=\"color: #333333\">&lt;<\/span>groupId<span style=\"color: #333333\">&gt;<\/span>org<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">apache<\/span><span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">kafka<\/span><span style=\"color: #333333\">&lt;\/<\/span>groupId<span style=\"color: #333333\">&gt;<\/span>\n<span style=\"color: #333333\">&lt;<\/span>artifactId<span style=\"color: #333333\">&gt;<\/span>kafka<span style=\"color: #333333\">-<\/span>streams<span style=\"color: #333333\">&lt;\/<\/span>artifactId<span style=\"color: #333333\">&gt;<\/span>\n<span style=\"color: #333333\">&lt;<\/span>version<span style=\"color: #333333\">&gt;<\/span><span style=\"color: #6600EE; font-weight: bold\">3.6<\/span><span style=\"color: #333333\">.<\/span><span style=\"color: #0000DD; font-weight: bold\">0<\/span><span style=\"color: #333333\">&lt;\/<\/span>version<span style=\"color: #333333\">&gt;<\/span>\n<span style=\"color: #333333\">&lt;\/<\/span>dependency<span style=\"color: #333333\">&gt;<\/span>\n<span style=\"color: #333333\">&lt;\/<\/span>dependencies<span style=\"color: #333333\">&gt;<\/span>\n<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Producer<\/h2>\n\n\n\n<p>Producer puts messages in the topic. The producer can be accessed from multiple threads. Here is the code. The key can be changed, same the payload type, with, of course, the right serializer and deserializer.<\/p>\n\n\n\n<!-- HTML generated using hilite.me --><div style=\"background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;\"><pre style=\"margin: 0; line-height: 125%\"><span style=\"color: #008800; font-weight: bold\">package<\/span> org<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">example<\/span><span style=\"color: #333333\">;<\/span>\n\n\n<span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">org.apache.kafka.clients.consumer.ConsumerConfig<\/span><span style=\"color: #333333\">;<\/span>\n<span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">org.apache.kafka.clients.producer.KafkaProducer<\/span><span style=\"color: #333333\">;<\/span>\n<span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">org.apache.kafka.clients.producer.ProducerConfig<\/span><span style=\"color: #333333\">;<\/span>\n<span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">org.apache.kafka.clients.producer.ProducerRecord<\/span><span style=\"color: #333333\">;<\/span>\n<span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">org.apache.kafka.common.serialization.LongSerializer<\/span><span style=\"color: #333333\">;<\/span>\n<span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">org.apache.kafka.common.serialization.StringSerializer<\/span><span style=\"color: #333333\">;<\/span>\n<span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">org.slf4j.Logger<\/span><span style=\"color: #333333\">;<\/span>\n<span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">org.slf4j.LoggerFactory<\/span><span style=\"color: #333333\">;<\/span>\n\n<span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">java.util.Date<\/span><span style=\"color: #333333\">;<\/span>\n<span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">java.util.Properties<\/span><span style=\"color: #333333\">;<\/span>\n\n<span style=\"color: #008800; font-weight: bold\">public<\/span> <span style=\"color: #008800; font-weight: bold\">class<\/span> <span style=\"color: #BB0066; font-weight: bold\">ProdStarter<\/span> <span style=\"color: #333333\">{<\/span>\n    <span style=\"color: #008800; font-weight: bold\">private<\/span> <span style=\"color: #008800; font-weight: bold\">static<\/span> <span style=\"color: #008800; font-weight: bold\">final<\/span> Logger log <span style=\"color: #333333\">=<\/span> LoggerFactory<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">getLogger<\/span><span style=\"color: #333333\">(<\/span>ProdStarter<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">class<\/span><span style=\"color: #333333\">);<\/span>\n\n    <span style=\"color: #008800; font-weight: bold\">public<\/span> <span style=\"color: #008800; font-weight: bold\">static<\/span> <span style=\"color: #333399; font-weight: bold\">void<\/span> <span style=\"color: #0066BB; font-weight: bold\">main<\/span><span style=\"color: #333333\">(<\/span>String<span style=\"color: #333333\">[]<\/span> args<span style=\"color: #333333\">)<\/span> <span style=\"color: #333333\">{<\/span>\n        <span style=\"color: #008800; font-weight: bold\">try<\/span> <span style=\"color: #333333\">{<\/span>\n            <span style=\"color: #008800; font-weight: bold\">new<\/span> <span style=\"color: #0066BB; font-weight: bold\">ProdStarter<\/span><span style=\"color: #333333\">().<\/span><span style=\"color: #0000CC\">start<\/span><span style=\"color: #333333\">();<\/span>\n        <span style=\"color: #333333\">}<\/span> <span style=\"color: #008800; font-weight: bold\">catch<\/span> <span style=\"color: #333333\">(<\/span>Exception e<span style=\"color: #333333\">)<\/span> <span style=\"color: #333333\">{<\/span>\n            e<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">printStackTrace<\/span><span style=\"color: #333333\">();<\/span>\n        <span style=\"color: #333333\">}<\/span>\n    <span style=\"color: #333333\">}<\/span>\n\n    <span style=\"color: #008800; font-weight: bold\">private<\/span> <span style=\"color: #333399; font-weight: bold\">void<\/span> <span style=\"color: #0066BB; font-weight: bold\">start<\/span><span style=\"color: #333333\">()<\/span> <span style=\"color: #008800; font-weight: bold\">throws<\/span> Exception <span style=\"color: #333333\">{<\/span>\n        KafkaProducer<span style=\"color: #333333\">&lt;<\/span>Long<span style=\"color: #333333\">,<\/span> String<span style=\"color: #333333\">&gt;<\/span> producer <span style=\"color: #333333\">=<\/span> getStringStringKafkaProducer<span style=\"color: #333333\">();<\/span>\n\n        <span style=\"color: #008800; font-weight: bold\">for<\/span> <span style=\"color: #333333\">(<\/span><span style=\"color: #333399; font-weight: bold\">int<\/span> i <span style=\"color: #333333\">=<\/span> <span style=\"color: #0000DD; font-weight: bold\">0<\/span><span style=\"color: #333333\">;<\/span> i <span style=\"color: #333333\">&lt;<\/span> <span style=\"color: #0000DD; font-weight: bold\">10<\/span><span style=\"color: #333333\">;<\/span> i<span style=\"color: #333333\">++)<\/span> <span style=\"color: #333333\">{<\/span>\n            <span style=\"color: #333399; font-weight: bold\">long<\/span> currentTimestamp <span style=\"color: #333333\">=<\/span> <span style=\"color: #008800; font-weight: bold\">new<\/span> Date<span style=\"color: #333333\">().<\/span><span style=\"color: #0000CC\">getTime<\/span><span style=\"color: #333333\">();<\/span>\n\n\n            ProducerRecord<span style=\"color: #333333\">&lt;<\/span>Long<span style=\"color: #333333\">,<\/span> String<span style=\"color: #333333\">&gt;<\/span> producerRecord <span style=\"color: #333333\">=<\/span>\n                    <span style=\"color: #008800; font-weight: bold\">new<\/span> ProducerRecord<span style=\"color: #333333\">&lt;&gt;(<\/span><span style=\"background-color: #fff0f0\">&quot;tester1&quot;<\/span><span style=\"color: #333333\">,<\/span> <span style=\"color: #333333\">(<\/span><span style=\"color: #333399; font-weight: bold\">long<\/span><span style=\"color: #333333\">)<\/span> i<span style=\"color: #333333\">,<\/span> <span style=\"background-color: #fff0f0\">&quot;this is the amount for the value - &quot;<\/span> <span style=\"color: #333333\">+<\/span> i <span style=\"color: #333333\">+<\/span> <span style=\"background-color: #fff0f0\">&quot; - here&quot;<\/span><span style=\"color: #333333\">);<\/span>\n\n            <span style=\"color: #888888\">\/\/ send data - asynchronous<\/span>\n            producer<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">send<\/span><span style=\"color: #333333\">(<\/span>producerRecord<span style=\"color: #333333\">);<\/span>\n        <span style=\"color: #333333\">}<\/span>\n\n\n        <span style=\"color: #888888\">\/\/ flush data - synchronous<\/span>\n        producer<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">flush<\/span><span style=\"color: #333333\">();<\/span>\n\n        <span style=\"color: #888888\">\/\/ flush and close producer<\/span>\n        producer<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">close<\/span><span style=\"color: #333333\">();<\/span>\n    <span style=\"color: #333333\">}<\/span>\n\n    <span style=\"color: #008800; font-weight: bold\">private<\/span> <span style=\"color: #008800; font-weight: bold\">static<\/span> KafkaProducer<span style=\"color: #333333\">&lt;<\/span>Long<span style=\"color: #333333\">,<\/span> String<span style=\"color: #333333\">&gt;<\/span> getStringStringKafkaProducer<span style=\"color: #333333\">()<\/span> <span style=\"color: #333333\">{<\/span>\n        String bootstrapServers <span style=\"color: #333333\">=<\/span> <span style=\"background-color: #fff0f0\">&quot;127.0.0.1:9092&quot;<\/span><span style=\"color: #333333\">;<\/span>\n\n        <span style=\"color: #888888\">\/\/ setup the producer<\/span>\n        Properties properties <span style=\"color: #333333\">=<\/span> <span style=\"color: #008800; font-weight: bold\">new<\/span> Properties<span style=\"color: #333333\">();<\/span>\n        properties<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">setProperty<\/span><span style=\"color: #333333\">(<\/span>ProducerConfig<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">BOOTSTRAP_SERVERS_CONFIG<\/span><span style=\"color: #333333\">,<\/span> bootstrapServers<span style=\"color: #333333\">);<\/span>\n        properties<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">setProperty<\/span><span style=\"color: #333333\">(<\/span>ProducerConfig<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">KEY_SERIALIZER_CLASS_CONFIG<\/span><span style=\"color: #333333\">,<\/span> LongSerializer<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">class<\/span><span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">getName<\/span><span style=\"color: #333333\">());<\/span>\n        properties<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">setProperty<\/span><span style=\"color: #333333\">(<\/span>ProducerConfig<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">VALUE_SERIALIZER_CLASS_CONFIG<\/span><span style=\"color: #333333\">,<\/span> StringSerializer<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">class<\/span><span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">getName<\/span><span style=\"color: #333333\">());<\/span>\n        properties<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">setProperty<\/span><span style=\"color: #333333\">(<\/span>ConsumerConfig<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">GROUP_ID_CONFIG<\/span><span style=\"color: #333333\">,<\/span> <span style=\"background-color: #fff0f0\">&quot;groupidhere&quot;<\/span><span style=\"color: #333333\">);<\/span>\n\n        <span style=\"color: #888888\">\/\/ one instance of producer is thread safe and enough for all application<\/span>\n        <span style=\"color: #888888\">\/\/ better performance than opening one for each thread or message<\/span>\n        KafkaProducer<span style=\"color: #333333\">&lt;<\/span>Long<span style=\"color: #333333\">,<\/span> String<span style=\"color: #333333\">&gt;<\/span> producer <span style=\"color: #333333\">=<\/span> <span style=\"color: #008800; font-weight: bold\">new<\/span> KafkaProducer<span style=\"color: #333333\">&lt;&gt;(<\/span>properties<span style=\"color: #333333\">);<\/span>\n        <span style=\"color: #008800; font-weight: bold\">return<\/span> producer<span style=\"color: #333333\">;<\/span>\n    <span style=\"color: #333333\">}<\/span>\n<span style=\"color: #333333\">}<\/span>\n<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Consumer<\/h2>\n\n\n\n<p>The example below of course is a proof of concept. <\/p>\n\n\n\n<!-- HTML generated using hilite.me --><div style=\"background: #ffffff; overflow:auto;width:auto;text-align: left; border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;\"><pre style=\"margin: 0; line-height: 125%\"><span style=\"color: #008800; font-weight: bold\">package<\/span> org<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">example<\/span><span style=\"color: #333333\">;<\/span>\n\n<span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">org.apache.kafka.clients.consumer.ConsumerConfig<\/span><span style=\"color: #333333\">;<\/span>\n<span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">org.apache.kafka.clients.consumer.ConsumerRecord<\/span><span style=\"color: #333333\">;<\/span>\n<span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">org.apache.kafka.clients.consumer.ConsumerRecords<\/span><span style=\"color: #333333\">;<\/span>\n<span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">org.apache.kafka.clients.consumer.KafkaConsumer<\/span><span style=\"color: #333333\">;<\/span>\n<span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">org.apache.kafka.common.PartitionInfo<\/span><span style=\"color: #333333\">;<\/span>\n<span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">org.apache.kafka.common.serialization.StringDeserializer<\/span><span style=\"color: #333333\">;<\/span>\n<span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">org.slf4j.Logger<\/span><span style=\"color: #333333\">;<\/span>\n<span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">org.slf4j.LoggerFactory<\/span><span style=\"color: #333333\">;<\/span>\n\n<span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">java.time.Duration<\/span><span style=\"color: #333333\">;<\/span>\n<span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">java.util.List<\/span><span style=\"color: #333333\">;<\/span>\n<span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">java.util.Map<\/span><span style=\"color: #333333\">;<\/span>\n<span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">java.util.Properties<\/span><span style=\"color: #333333\">;<\/span>\n\n<span style=\"color: #008800; font-weight: bold\">public<\/span> <span style=\"color: #008800; font-weight: bold\">class<\/span> <span style=\"color: #BB0066; font-weight: bold\">ConsumerStarter<\/span> <span style=\"color: #333333\">{<\/span>\n    <span style=\"color: #008800; font-weight: bold\">private<\/span> <span style=\"color: #008800; font-weight: bold\">static<\/span> <span style=\"color: #008800; font-weight: bold\">final<\/span> Logger log <span style=\"color: #333333\">=<\/span> LoggerFactory<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">getLogger<\/span><span style=\"color: #333333\">(<\/span>ProdStarter<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">class<\/span><span style=\"color: #333333\">);<\/span>\n\n    <span style=\"color: #008800; font-weight: bold\">public<\/span> <span style=\"color: #008800; font-weight: bold\">static<\/span> <span style=\"color: #333399; font-weight: bold\">void<\/span> <span style=\"color: #0066BB; font-weight: bold\">main<\/span><span style=\"color: #333333\">(<\/span>String<span style=\"color: #333333\">[]<\/span> args<span style=\"color: #333333\">)<\/span> <span style=\"color: #333333\">{<\/span>\n        <span style=\"color: #008800; font-weight: bold\">try<\/span> <span style=\"color: #333333\">{<\/span>\n            <span style=\"color: #008800; font-weight: bold\">new<\/span> <span style=\"color: #0066BB; font-weight: bold\">ConsumerStarter<\/span><span style=\"color: #333333\">().<\/span><span style=\"color: #0000CC\">start<\/span><span style=\"color: #333333\">();<\/span>\n        <span style=\"color: #333333\">}<\/span> <span style=\"color: #008800; font-weight: bold\">catch<\/span> <span style=\"color: #333333\">(<\/span>Exception e<span style=\"color: #333333\">)<\/span> <span style=\"color: #333333\">{<\/span>\n            e<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">printStackTrace<\/span><span style=\"color: #333333\">();<\/span>\n        <span style=\"color: #333333\">}<\/span>\n    <span style=\"color: #333333\">}<\/span>\n\n    <span style=\"color: #008800; font-weight: bold\">private<\/span> <span style=\"color: #333399; font-weight: bold\">void<\/span> <span style=\"color: #0066BB; font-weight: bold\">start<\/span><span style=\"color: #333333\">()<\/span> <span style=\"color: #008800; font-weight: bold\">throws<\/span> Exception <span style=\"color: #333333\">{<\/span>\n        String bootstrapServers <span style=\"color: #333333\">=<\/span> <span style=\"background-color: #fff0f0\">&quot;127.0.0.1:9092&quot;<\/span><span style=\"color: #333333\">;<\/span>\n\n        Properties properties <span style=\"color: #333333\">=<\/span> <span style=\"color: #008800; font-weight: bold\">new<\/span> Properties<span style=\"color: #333333\">();<\/span>\n        properties<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">setProperty<\/span><span style=\"color: #333333\">(<\/span>ConsumerConfig<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">BOOTSTRAP_SERVERS_CONFIG<\/span><span style=\"color: #333333\">,<\/span> bootstrapServers<span style=\"color: #333333\">);<\/span>\n        properties<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">setProperty<\/span><span style=\"color: #333333\">(<\/span>ConsumerConfig<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">KEY_DESERIALIZER_CLASS_CONFIG<\/span><span style=\"color: #333333\">,<\/span> StringDeserializer<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">class<\/span><span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">getName<\/span><span style=\"color: #333333\">());<\/span>\n        properties<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">setProperty<\/span><span style=\"color: #333333\">(<\/span>ConsumerConfig<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">VALUE_DESERIALIZER_CLASS_CONFIG<\/span><span style=\"color: #333333\">,<\/span> StringDeserializer<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">class<\/span><span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">getName<\/span><span style=\"color: #333333\">());<\/span>\n\n        <span style=\"color: #888888\">\/\/ very important if for a new group id you want to start from very beginning, as<\/span>\n        <span style=\"color: #888888\">\/\/ the default value is &quot;latest&quot; that means that even for a new group id config you still<\/span>\n        <span style=\"color: #888888\">\/\/ get messages starting &quot;now&quot;, not &quot;earliest&quot;<\/span>\n        properties<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">setProperty<\/span><span style=\"color: #333333\">(<\/span>ConsumerConfig<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">AUTO_OFFSET_RESET_CONFIG<\/span><span style=\"color: #333333\">,<\/span> <span style=\"background-color: #fff0f0\">&quot;earliest&quot;<\/span><span style=\"color: #333333\">);<\/span>\n        properties<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">setProperty<\/span><span style=\"color: #333333\">(<\/span>ConsumerConfig<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">GROUP_ID_CONFIG<\/span><span style=\"color: #333333\">,<\/span> <span style=\"background-color: #fff0f0\">&quot;a&quot;<\/span><span style=\"color: #333333\">);<\/span>\n\n        KafkaConsumer<span style=\"color: #333333\">&lt;<\/span>String<span style=\"color: #333333\">,<\/span> String<span style=\"color: #333333\">&gt;<\/span> consumer <span style=\"color: #333333\">=<\/span> <span style=\"color: #008800; font-weight: bold\">new<\/span> KafkaConsumer<span style=\"color: #333333\">&lt;&gt;(<\/span>properties<span style=\"color: #333333\">);<\/span>\n\n        <span style=\"color: #888888\">\/\/ just list the topics to see what&#39;s there<\/span>\n        Map<span style=\"color: #333333\">&lt;<\/span>String<span style=\"color: #333333\">,<\/span> List<span style=\"color: #333333\">&lt;<\/span>PartitionInfo<span style=\"color: #333333\">&gt;&gt;<\/span> topics <span style=\"color: #333333\">=<\/span> consumer<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">listTopics<\/span><span style=\"color: #333333\">();<\/span>\n        topics<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">forEach<\/span><span style=\"color: #333333\">((<\/span>key<span style=\"color: #333333\">,<\/span> partitions<span style=\"color: #333333\">)<\/span> <span style=\"color: #333333\">-&gt;<\/span> <span style=\"color: #333333\">{<\/span>\n            System<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">out<\/span><span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">println<\/span><span style=\"color: #333333\">(<\/span><span style=\"background-color: #fff0f0\">&quot;key: &quot;<\/span> <span style=\"color: #333333\">+<\/span> key<span style=\"color: #333333\">);<\/span>\n            partitions<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">forEach<\/span><span style=\"color: #333333\">((<\/span>part<span style=\"color: #333333\">)<\/span> <span style=\"color: #333333\">-&gt;<\/span> <span style=\"color: #333333\">{<\/span>\n                String top <span style=\"color: #333333\">=<\/span> part<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">topic<\/span><span style=\"color: #333333\">();<\/span>\n                System<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">out<\/span><span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">println<\/span><span style=\"color: #333333\">(<\/span><span style=\"background-color: #fff0f0\">&quot;topic: &quot;<\/span> <span style=\"color: #333333\">+<\/span> top<span style=\"color: #333333\">);<\/span>\n            <span style=\"color: #333333\">});<\/span>\n        <span style=\"color: #333333\">});<\/span>\n\n        <span style=\"color: #888888\">\/\/ start reading messages<\/span>\n        consumer<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">subscribe<\/span><span style=\"color: #333333\">(<\/span>List<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">of<\/span><span style=\"color: #333333\">(<\/span><span style=\"background-color: #fff0f0\">&quot;tester1&quot;<\/span><span style=\"color: #333333\">));<\/span>\n        <span style=\"color: #888888\">\/\/ poll for new data<\/span>\n        <span style=\"color: #008800; font-weight: bold\">while<\/span><span style=\"color: #333333\">(<\/span><span style=\"color: #008800; font-weight: bold\">true<\/span><span style=\"color: #333333\">){<\/span>\n            ConsumerRecords<span style=\"color: #333333\">&lt;<\/span>String<span style=\"color: #333333\">,<\/span> String<span style=\"color: #333333\">&gt;<\/span> records <span style=\"color: #333333\">=<\/span>\n                    consumer<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">poll<\/span><span style=\"color: #333333\">(<\/span>Duration<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">ofMillis<\/span><span style=\"color: #333333\">(<\/span><span style=\"color: #0000DD; font-weight: bold\">100<\/span><span style=\"color: #333333\">));<\/span>\n\n            <span style=\"color: #008800; font-weight: bold\">for<\/span> <span style=\"color: #333333\">(<\/span>ConsumerRecord<span style=\"color: #333333\">&lt;<\/span>String<span style=\"color: #333333\">,<\/span> String<span style=\"color: #333333\">&gt;<\/span> record <span style=\"color: #333333\">:<\/span> records<span style=\"color: #333333\">){<\/span>\n                System<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">out<\/span><span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">println<\/span><span style=\"color: #333333\">(<\/span><span style=\"background-color: #fff0f0\">&quot;Key: &quot;<\/span> <span style=\"color: #333333\">+<\/span> record<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">key<\/span><span style=\"color: #333333\">()<\/span> <span style=\"color: #333333\">+<\/span> <span style=\"background-color: #fff0f0\">&quot;, Value: &quot;<\/span> <span style=\"color: #333333\">+<\/span> record<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">value<\/span><span style=\"color: #333333\">());<\/span>\n                System<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">out<\/span><span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">println<\/span><span style=\"color: #333333\">(<\/span><span style=\"background-color: #fff0f0\">&quot;Partition: &quot;<\/span> <span style=\"color: #333333\">+<\/span> record<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">partition<\/span><span style=\"color: #333333\">()<\/span> <span style=\"color: #333333\">+<\/span> <span style=\"background-color: #fff0f0\">&quot;, Offset:&quot;<\/span> <span style=\"color: #333333\">+<\/span> record<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">offset<\/span><span style=\"color: #333333\">());<\/span>\n            <span style=\"color: #333333\">}<\/span>\n        <span style=\"color: #333333\">}<\/span>\n    <span style=\"color: #333333\">}<\/span>\n<span style=\"color: #333333\">}<\/span>\n<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Streams<\/h2>\n\n\n\n<p>Streams are a kind of consumers of topic messages with a lot of functionality associated with them:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You can handle message structure and content including changing the key and the payload<\/li>\n\n\n\n<li>Filtering<\/li>\n\n\n\n<li>Grouping<\/li>\n\n\n\n<li>At the end you can post to another topic the updated messages<\/li>\n\n\n\n<li>Use temporary storage provided by Kafka for groups, counts and other operations<\/li>\n<\/ul>\n\n\n\n<p>Here is a sample code of how to register a stream against a topic and then consume the contents<\/p>\n\n\n\n<div class=\"java\">\n<!-- HTML generated using hilite.me --><div style=\"background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;\"><table><tr><td><pre style=\"margin: 0; line-height: 125%\"> 1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49<\/pre><\/td><td><pre style=\"margin: 0; line-height: 125%\"><span style=\"color: #008800; font-weight: bold\">package<\/span> org<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">example<\/span><span style=\"color: #333333\">;<\/span>\n\n<span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">org.apache.kafka.common.serialization.Serdes<\/span><span style=\"color: #333333\">;<\/span>\n<span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">org.apache.kafka.common.utils.Bytes<\/span><span style=\"color: #333333\">;<\/span>\n<span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">org.apache.kafka.streams.KafkaStreams<\/span><span style=\"color: #333333\">;<\/span>\n<span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">org.apache.kafka.streams.KeyValue<\/span><span style=\"color: #333333\">;<\/span>\n<span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">org.apache.kafka.streams.StreamsBuilder<\/span><span style=\"color: #333333\">;<\/span>\n<span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">org.apache.kafka.streams.StreamsConfig<\/span><span style=\"color: #333333\">;<\/span>\n<span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">org.apache.kafka.streams.kstream.*<\/span><span style=\"color: #333333\">;<\/span>\n<span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">org.apache.kafka.streams.state.KeyValueStore<\/span><span style=\"color: #333333\">;<\/span>\n\n<span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">java.util.Arrays<\/span><span style=\"color: #333333\">;<\/span>\n<span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">java.util.List<\/span><span style=\"color: #333333\">;<\/span>\n<span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">java.util.Properties<\/span><span style=\"color: #333333\">;<\/span>\n\n<span style=\"color: #008800; font-weight: bold\">public<\/span> <span style=\"color: #008800; font-weight: bold\">class<\/span> <span style=\"color: #BB0066; font-weight: bold\">StreamerTest<\/span> <span style=\"color: #333333\">{<\/span>\n    <span style=\"color: #008800; font-weight: bold\">public<\/span> <span style=\"color: #008800; font-weight: bold\">static<\/span> <span style=\"color: #333399; font-weight: bold\">void<\/span> <span style=\"color: #0066BB; font-weight: bold\">main<\/span><span style=\"color: #333333\">(<\/span>String<span style=\"color: #333333\">[]<\/span> args<span style=\"color: #333333\">)<\/span> <span style=\"color: #333333\">{<\/span>\n        <span style=\"color: #008800; font-weight: bold\">try<\/span> <span style=\"color: #333333\">{<\/span>\n            <span style=\"color: #008800; font-weight: bold\">new<\/span> <span style=\"color: #0066BB; font-weight: bold\">StreamerTest<\/span><span style=\"color: #333333\">().<\/span><span style=\"color: #0000CC\">start<\/span><span style=\"color: #333333\">();<\/span>\n        <span style=\"color: #333333\">}<\/span> <span style=\"color: #008800; font-weight: bold\">catch<\/span> <span style=\"color: #333333\">(<\/span>Exception e<span style=\"color: #333333\">)<\/span> <span style=\"color: #333333\">{<\/span>\n            e<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">printStackTrace<\/span><span style=\"color: #333333\">();<\/span>\n        <span style=\"color: #333333\">}<\/span>\n    <span style=\"color: #333333\">}<\/span>\n\n    <span style=\"color: #008800; font-weight: bold\">private<\/span> <span style=\"color: #333399; font-weight: bold\">void<\/span> <span style=\"color: #0066BB; font-weight: bold\">start<\/span><span style=\"color: #333333\">()<\/span> <span style=\"color: #008800; font-weight: bold\">throws<\/span> Exception <span style=\"color: #333333\">{<\/span>\n        Properties props <span style=\"color: #333333\">=<\/span> <span style=\"color: #008800; font-weight: bold\">new<\/span> Properties<span style=\"color: #333333\">();<\/span>\n        props<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">put<\/span><span style=\"color: #333333\">(<\/span>StreamsConfig<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">APPLICATION_ID_CONFIG<\/span><span style=\"color: #333333\">,<\/span> <span style=\"background-color: #fff0f0\">&quot;wordcount-application&quot;<\/span><span style=\"color: #333333\">);<\/span>\n        props<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">put<\/span><span style=\"color: #333333\">(<\/span>StreamsConfig<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">BOOTSTRAP_SERVERS_CONFIG<\/span><span style=\"color: #333333\">,<\/span> <span style=\"background-color: #fff0f0\">&quot;localhost:9092&quot;<\/span><span style=\"color: #333333\">);<\/span>\n        props<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">put<\/span><span style=\"color: #333333\">(<\/span>StreamsConfig<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">DEFAULT_KEY_SERDE_CLASS_CONFIG<\/span><span style=\"color: #333333\">,<\/span> Serdes<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">Long<\/span><span style=\"color: #333333\">().<\/span><span style=\"color: #0000CC\">getClass<\/span><span style=\"color: #333333\">());<\/span>\n        props<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">put<\/span><span style=\"color: #333333\">(<\/span>StreamsConfig<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">DEFAULT_VALUE_SERDE_CLASS_CONFIG<\/span><span style=\"color: #333333\">,<\/span> Serdes<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">String<\/span><span style=\"color: #333333\">().<\/span><span style=\"color: #0000CC\">getClass<\/span><span style=\"color: #333333\">());<\/span>\n\n        StreamsBuilder builder <span style=\"color: #333333\">=<\/span> <span style=\"color: #008800; font-weight: bold\">new<\/span> StreamsBuilder<span style=\"color: #333333\">();<\/span>\n        KStream<span style=\"color: #333333\">&lt;<\/span>Long<span style=\"color: #333333\">,<\/span> String<span style=\"color: #333333\">&gt;<\/span> textLines <span style=\"color: #333333\">=<\/span> builder<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">stream<\/span><span style=\"color: #333333\">(<\/span><span style=\"background-color: #fff0f0\">&quot;tester1&quot;<\/span><span style=\"color: #333333\">);<\/span>\n        textLines\n                <span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">mapValues<\/span><span style=\"color: #333333\">(<\/span>value <span style=\"color: #333333\">-&gt;<\/span> value <span style=\"color: #333333\">+<\/span> <span style=\"background-color: #fff0f0\">&quot; suffix&quot;<\/span><span style=\"color: #333333\">)<\/span>\n                <span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">flatMapValues<\/span><span style=\"color: #333333\">(<\/span>value <span style=\"color: #333333\">-&gt;<\/span> List<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">of<\/span><span style=\"color: #333333\">(<\/span>value<span style=\"color: #333333\">,<\/span> value <span style=\"color: #333333\">+<\/span> <span style=\"background-color: #fff0f0\">&quot;(a)&quot;<\/span><span style=\"color: #333333\">))<\/span>\n                <span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">filter<\/span><span style=\"color: #333333\">((<\/span>key<span style=\"color: #333333\">,<\/span> value<span style=\"color: #333333\">)<\/span> <span style=\"color: #333333\">-&gt;<\/span> key <span style=\"color: #333333\">%<\/span> <span style=\"color: #0000DD; font-weight: bold\">2<\/span> <span style=\"color: #333333\">==<\/span> <span style=\"color: #0000DD; font-weight: bold\">0<\/span><span style=\"color: #333333\">)<\/span>\n                <span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">map<\/span><span style=\"color: #333333\">((<\/span>key<span style=\"color: #333333\">,<\/span> val<span style=\"color: #333333\">)<\/span> <span style=\"color: #333333\">-&gt;<\/span> <span style=\"color: #008800; font-weight: bold\">new<\/span> KeyValue<span style=\"color: #333333\">&lt;&gt;(<\/span>key <span style=\"color: #333333\">+<\/span> <span style=\"color: #0000DD; font-weight: bold\">10<\/span><span style=\"color: #333333\">,<\/span> <span style=\"background-color: #fff0f0\">&quot;prefix - &quot;<\/span> <span style=\"color: #333333\">+<\/span> val<span style=\"color: #333333\">))<\/span>\n                <span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">foreach<\/span><span style=\"color: #333333\">((<\/span>key<span style=\"color: #333333\">,<\/span> value<span style=\"color: #333333\">)<\/span> <span style=\"color: #333333\">-&gt;<\/span> <span style=\"color: #333333\">{<\/span>\n                    String message <span style=\"color: #333333\">=<\/span> String<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">format<\/span><span style=\"color: #333333\">(<\/span><span style=\"background-color: #fff0f0\">&quot;only value: %d &gt;&gt;%s&lt;&lt;&quot;<\/span><span style=\"color: #333333\">,<\/span> key<span style=\"color: #333333\">,<\/span> value<span style=\"color: #333333\">);<\/span>\n\n                    System<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">out<\/span><span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">println<\/span><span style=\"color: #333333\">(<\/span>message<span style=\"color: #333333\">);<\/span>\n                <span style=\"color: #333333\">});<\/span>\n\n        KafkaStreams streams <span style=\"color: #333333\">=<\/span> <span style=\"color: #008800; font-weight: bold\">new<\/span> KafkaStreams<span style=\"color: #333333\">(<\/span>builder<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">build<\/span><span style=\"color: #333333\">(),<\/span> props<span style=\"color: #333333\">);<\/span>\n        streams<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">start<\/span><span style=\"color: #333333\">();<\/span>\n    <span style=\"color: #333333\">}<\/span>\n\n<span style=\"color: #333333\">}<\/span>\n<\/pre><\/td><\/tr><\/table><\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Various Commands<\/h2>\n\n\n\n<p>Here are a number of commands. It is easy to figure out what they do, however you need those samples to follow the model. <\/p>\n\n\n\n<!-- HTML generated using hilite.me --><div style=\"background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;\"><pre style=\"margin: 0; line-height: 125%\">kafka-topics.sh --create --topic quickstart-events --bootstrap-server localhost:9092\nkafka-topics.sh --describe --topic quickstart-events --bootstrap-server localhost:9092\nkafka-console-producer.sh --topic quickstart-events --bootstrap-server localhost:9092\nkafka-console-consumer.sh --topic quickstart-events --from-beginning --bootstrap-server localhost:9092\nkafka-topics.sh --bootstrap-server localhost:9092 --create --topic tester1  --partitions 20 --replication-factor 3\nkafka-consumer-groups.bat --list --bootstrap-server localhost:9092\nkafka-topics.bat --bootstrap-server=localhost:9092 --list\nkafka-consumer-groups.bat --bootstrap-server=localhost:9092 --list\nkafka-console-consumer.bat --bootstrap-server localhost:9092 --topic tester1\n<\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>This is a short article about how to setup a Kafka application up and running.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-52","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/coding101.xyz\/index.php?rest_route=\/wp\/v2\/posts\/52","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/coding101.xyz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coding101.xyz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coding101.xyz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coding101.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=52"}],"version-history":[{"count":15,"href":"https:\/\/coding101.xyz\/index.php?rest_route=\/wp\/v2\/posts\/52\/revisions"}],"predecessor-version":[{"id":94,"href":"https:\/\/coding101.xyz\/index.php?rest_route=\/wp\/v2\/posts\/52\/revisions\/94"}],"wp:attachment":[{"href":"https:\/\/coding101.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=52"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coding101.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=52"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coding101.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=52"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}