diff --git a/README.md b/README.md index 649cd93b..a02c3495 100644 --- a/README.md +++ b/README.md @@ -164,7 +164,11 @@ producer.on('ready', function() { // converted to a Buffer automatically, but we're being // explicit here for the sake of example. message: new Buffer('Awesome message'), - + // for keyed messages, we also specify the key - note that this field is optional + key: 'Stormwind', + // optionally we can manually specify a partition for the message + // this defaults to -1 - which will use librdkafka's default partitioner (consistent random for keyed messages, random for unkeyed messages) + partition: 0, // The topic object we created above topic: topic }, function(err) { diff --git a/src/producer.cc b/src/producer.cc index 778316e4..2cc4f045 100644 --- a/src/producer.cc +++ b/src/producer.cc @@ -415,7 +415,8 @@ ProducerMessage::ProducerMessage(v8::Local obj, Topic * topic): m_is_empty(true) { // We have this bad boy now - m_partition = GetParameter(obj, "partition", 0); + m_partition = + GetParameter(obj, "partition", RdKafka::Topic::PARTITION_UA); if (m_partition < 0) { m_partition = RdKafka::Topic::PARTITION_UA; // this is just -1