szaszm commented on a change in pull request #712: MINIFICPP-1047 Add property 
"Drop empty flow files" to PublishKafka
URL: https://github.com/apache/nifi-minifi-cpp/pull/712#discussion_r368582441
 
 

 ##########
 File path: extensions/librdkafka/PublishKafka.cpp
 ##########
 @@ -639,6 +647,17 @@ void PublishKafka::onTrigger(const 
std::shared_ptr<core::ProcessContext> &contex
     PublishKafka::ReadCallback callback(max_flow_seg_size, kafkaKey, 
thisTopic->getTopic(), conn->getConnection(), flowFile,
                                         attributeNameRegex, messages, 
flow_file_index);
     session->read(flowFile, &callback);
+
+    bool dropEmptyFlowFiles;
+    if (!callback.called_ && 
context->getProperty(DropEmptyFlowFiles.getName(), dropEmptyFlowFiles) && 
!dropEmptyFlowFiles) {
 
 Review comment:
   Producing the kafka message was part of the callback even before my changes. 
The issue is that when there is no `ResourceClaim`, `ProcessSession` doesn't 
call the callback and therefore we have no way of sending the message.
   
   I have extended the callback to handle empty flow files and made sure it's 
called with the above lines. The callback will be called exactly when it was 
not called and the used opted in for the correct behavior by setting 
`DropEmptyFlowFiles` to false.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to