<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Kafka Key not populated (PublishKafkaRecord) in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Kafka-Key-not-populated-PublishKafkaRecord/m-p/336651#M232335</link>
    <description>&lt;P&gt;I am using PublishKafkaRecord to produce Kafka messages from the incoming Json data.&amp;nbsp; &amp;nbsp;The json data has the right field to be used as the key to the Kafka message but the kafka key is not populated.&amp;nbsp; &amp;nbsp;Here's what I did (using Nifi 1.12.1).&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;1. `GenerateFlowFile` produces a record with the future kafka key (i.e. 'metadata.aggregateId' field)&lt;BR /&gt;2. Used `UpdateAttribute` processor to add an attribute called 'kafka.key' with 'metadata.aggregateId' as its value&lt;BR /&gt;3. `PublishKafkaRecord` has its `Message Key Field` as ${kafka.key}&lt;BR /&gt;4. Produced Kafka message key is null&lt;BR /&gt;5. `LogAttribute` shows all necessary hooks are there&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2022-02-19_10-12-44.png" style="width: 999px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/33621iAC2B4DDFF060CA91/image-size/large?v=v2&amp;amp;px=999" role="button" title="2022-02-19_10-12-44.png" alt="2022-02-19_10-12-44.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;And, here's the application log:&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;2022-02-19 17:57:40,401 INFO [Timer-Driven Process Thread-10] o.a.n.processors.standard.LogAttribute LogAttribute[id=e9b431f7-6784-1a90-8110-78386da99314] logging for flow file StandardFlowFileRecord[uuid=f495c59f-fdc6-4762-932e-f478a182039d,claim=StandardContentClaim [resourceClaim=StandardResourceClaim[id=1645226154214-9, container=default, section=9], offset=36854, length=783],offset=0,name=f495c59f-fdc6-4762-932e-f478a182039d,size=783]
--------------------------------------------------
Standard FlowFile Attributes
Key: 'entryDate'
        Value: 'Sat Feb 19 17:57:40 UTC 2022'
Key: 'lineageStartDate'
        Value: 'Sat Feb 19 17:57:40 UTC 2022'
Key: 'fileSize'
        Value: '783'
FlowFile Attribute Map Content
Key: 'filename'
        Value: 'f495c59f-fdc6-4762-932e-f478a182039d'
Key: 'kafka.key'
        Value: 'metadata.aggregateId'
Key: 'msg.count'
        Value: '1'
Key: 'path'
        Value: './'
Key: 'uuid'
        Value: 'f495c59f-fdc6-4762-932e-f478a182039d'
--------------------------------------------------
{
  "metadata": {
    "aggregateId": "ABC123",
    "aggregateEventOrder": 2,
    "aggregateRepositoryId": "mdm@ABC",
    "aggregateType": "foo.bar.v1.BazType",
    "appId": "mdm",
    "businessKey": "ABC123",
    "correlationId": "aaaaaaa-403b-4856-a4d1-f07ff84064a6",
    "eventId": "bbbbbbb-c061-492e-a66a-9e63e2906e39",
    "eventType": "VIS",
    "eventMessageVersion": "1.0",
    "eventRecordedTime": 1519168559357,
    "qualifiedEventName": "foo.bar.v1.BazTypeChangedEvent",
    "userLoginId": 0,
    "userFirstName": "John",
    "userLastName": "Doe",
    "userLoginName": "app-abcd",
    "workBranch": "ABC",
    "changeType": "CREATE",
    "uploadNumber": "U38"
  },
  "data": {
    "_documentation": "simple demo data",
    "code": "ABC123",
    "description": "N/A"
  }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;What am I missing here?&amp;nbsp;&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/29290"&gt;@sdairs&lt;/a&gt;&amp;nbsp;'s explanation was helpful in &lt;A href="https://stackoverflow.com/questions/66836784/set-message-key-of-kafka-topic-from-apache-nifi/71188008#71188008" target="_self"&gt;stackoverflow&lt;/A&gt; but did not work for me.&lt;/P&gt;&lt;P&gt;Thanks!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 19 Feb 2022 20:06:43 GMT</pubDate>
    <dc:creator>CloudNaive</dc:creator>
    <dc:date>2022-02-19T20:06:43Z</dc:date>
  </channel>
</rss>

