You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2020/09/19 12:49:42 UTC
[GitHub] [kafka] omkreddy commented on a change in pull request #9254: KAFKA-10462: Added support to pass headers in producerPerformance script
omkreddy commented on a change in pull request #9254:
URL: https://github.com/apache/kafka/pull/9254#discussion_r491421315
##########
File path: tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java
##########
@@ -87,6 +88,11 @@ public static void main(String[] args) throws Exception {
payloadByteList.add(payload.getBytes(StandardCharsets.UTF_8));
}
}
+
+ Properties headerProps = new Properties();
+ if (headersPath != null) {
+ headerProps.putAll(Utils.loadProps(headersPath));
Review comment:
@vgvineet4 Thanks for the PR. we are adding same header values for each record. Should we set different values for each record? maybe add string header value?
##########
File path: tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java
##########
@@ -132,12 +138,16 @@ public static void main(String[] args) throws Exception {
transactionStartTime = System.currentTimeMillis();
}
-
if (payloadFilePath != null) {
payload = payloadByteList.get(random.nextInt(payloadByteList.size()));
}
record = new ProducerRecord<>(topicName, payload);
-
+ Enumeration e = headerProps.propertyNames();
+ while (e.hasMoreElements()) {
+ String key = (String) e.nextElement();
+ System.out.println(key + " -- " + headerProps.getProperty(key));
+ record.headers().add(key, headerProps.getProperty(key).getBytes("UTF-8"));
Review comment:
Instead of adding headers each time, maybe we can pre-create the headers list and pass to ProducerRecord() constructor.
----------------------------------------------------------------
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:
users@infra.apache.org