fgerlits commented on a change in pull request #1037:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1037#discussion_r599586424



##########
File path: extensions/librdkafka/PublishKafka.cpp
##########
@@ -925,12 +931,10 @@ void PublishKafka::onTrigger(const 
std::shared_ptr<core::ProcessContext> &contex
     }
 
     std::string kafkaKey;
-    kafkaKey = "";
-    if (context->getDynamicProperty(MessageKeyField, kafkaKey, flowFile) && 
!kafkaKey.empty()) {
-      logger_->log_debug("PublishKafka: Message Key Field [%s]", kafkaKey);
-    } else {
+    if (!context->getProperty(KafkaKey, kafkaKey, flowFile) || 
kafkaKey.empty()) {

Review comment:
       It's complicated.  `MessageKeyField` used to "work" in the sense that if 
you set it (e.g. to `kafka.message.key` or `${kafka.message.key}`) then every 
message sent to Kafka would have the message key set to this literal value 
("kafka.message.key" or "${kafka.message.key}") without any substitution, i.e. 
all messages would have the same key.
   
   The description of the `MessageKeyField` property was "The name of a field 
in the Input Records that should be used as the Key for the Kafka message. 
Supports Expression Language: true (will be evaluated using flow file 
attributes)", every part of which is false.
   
   I hope nobody was using this, but I think that silently changing the message 
keys to the flow file UUID (which is what will happen if you were using 
`MessageKeyField` previously and don't change anything) is better than keeping 
the old behavior where every message had the same key.  Message keys are 
supposed to be unique.
   
   What do you think of keeping the behavior as it is, but adding an error log 
if `MessageKeyField` is set?




-- 
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]


Reply via email to