You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/01/31 01:39:00 UTC

[GitHub] dubeejw commented on a change in pull request #241: Allow producer to batch messages

dubeejw commented on a change in pull request #241: Allow producer to batch messages
URL: https://github.com/apache/incubator-openwhisk-package-kafka/pull/241#discussion_r164933121
 
 

 ##########
 File path: action/messageHubProduce.py
 ##########
 @@ -108,6 +105,42 @@ def main(params):
 
     return result
 
+def produceBatchedMessages(producer, topic, messageKey, values):
+    logging.info("Producing batched messages")
+
+    if messageKey is not None:
+        for val in values:
+            producer.send(topic, bytes(val, 'utf-8'), key=bytes(messageKey, 'utf-8'))
+    else:
+        for val in values:
+            producer.send(topic, bytes(val, 'utf-8'))
+
+    producer.flush()
 
 Review comment:
   Cannot get partition and offset now for log statement?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services