{"id":9726,"date":"2023-01-09T14:17:11","date_gmt":"2023-01-09T19:17:11","guid":{"rendered":"https:\/\/www.rushworth.us\/lisa\/?p=9726"},"modified":"2023-01-09T14:17:12","modified_gmt":"2023-01-09T19:17:12","slug":"kafka-producer-sending-a-message-with-a-key","status":"publish","type":"post","link":"https:\/\/www.rushworth.us\/lisa\/?p=9726","title":{"rendered":"Kafka Producer &#8211; Sending a Message with a Key"},"content":{"rendered":"\n<p>I needed to test sending messages into a topic where the cleanup policy is compact (keep the most recent data for each key) &#8230; which means I needed a quick way to send a message <em>with a key<\/em> to Kafka. Fortunately, the kafka-consume-producer script supports key parsing. You just need to include a few &#8211;property parameters when running the script. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n.\/kafka-console-producer.sh --bootstrap-server kafka.example.com:9092 --topic ljrtesting --property &quot;parse.key=true&quot; --property &quot;key.separator=:&quot;\n<\/pre><\/div>\n\n\n<p>When you send messages, they are in the format Key&lt;deliminator>Message &#8212; so &#8220;LJRKey:1&#8221; will send a message with the <em>key<\/em> of &#8220;LJRKey&#8221; and the message content of &#8220;1&#8221;. <\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I needed to test sending messages into a topic where the cleanup policy is compact (keep the most recent data for each key) &#8230; which means I needed a quick way to send a message with a key to Kafka. Fortunately, the kafka-consume-producer script supports key parsing. You just need to include a few &#8211;property &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1762],"tags":[1361],"class_list":["post-9726","post","type-post","status-publish","format-standard","hentry","category-kafka","tag-kafka"],"_links":{"self":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/9726","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9726"}],"version-history":[{"count":1,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/9726\/revisions"}],"predecessor-version":[{"id":9727,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/9726\/revisions\/9727"}],"wp:attachment":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9726"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9726"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9726"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}