markap14 commented on PR #6131:
URL: https://github.com/apache/nifi/pull/6131#issuecomment-1224840438

   @greyp9 So, given the above (i will address in reverse order because I think 
you started with the hardest to describe and got easier as you went down the 
list) :) ...
   
   The last point, about "Message Key Field" property I think is perfectly 
accurate.
   
   As for the headers:
   - I think what you said is accurate, but to clarify:
   - If (Use Wrapper) - the headers to send would be a single header. Its name 
would be "headerA" and its value would be "headerAValue". FlowFile attributes 
would not be sent as headers.
   - Else, the headers would be any FlowFile attribute that matches the 
"Attributes to Send as Headers (Regex)" property
   
   Now, as for the other...
   ```
   if (Use Wrapper) {
       Kafka Record:
       Key = { "type": "person" }
       Value = { "name": "Mark", "number": 49 }
       Headers = A single header with name "headerA", value "headerAValue"
   } else {
       Kafka Record:
       Key = <Depends on the value of the 'Message Key Field' property>
       Value = <The entire JSON payload. I.e.,:>
       {
                          "key": {
                              "type": "person"
                           },
                          "value": {
                               "name": "Mark",
                               "number": 49
                          },
                          "headers": {
                                "headerA": "headerAValue"
                          }
        }
       Headers = <Whatever matches the 'Attributes to Send as Headers (Regex)' 
property>
   }
   ```
   
   So, in short, if Use Wrapper, the incoming FlowFile must have 3 fields:
   Key. This becomes the kafka message key.
   Value. This becomes the contents of the kafka message.
   Headers. This becomes the headers attached to the kafka message.
   Any other fields, such as metadata, would be ignored.
   
   If NOT using wrapper, it would function as it always has. The entire 
contents of the Record go as the kafka message payload. The key and headers are 
determined based on the configured "Message Key Field" and "Attributes to Send 
as Headers (Regex)" properties.
   
   Does that make sense? Or have I confused things even worse? :)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to