summaryrefslogtreecommitdiff
path: root/kafka/producer
diff options
context:
space:
mode:
Diffstat (limited to 'kafka/producer')
-rw-r--r--kafka/producer/kafka.py3
-rw-r--r--kafka/producer/sender.py16
2 files changed, 15 insertions, 4 deletions
diff --git a/kafka/producer/kafka.py b/kafka/producer/kafka.py
index 7aa24b3..fc60e78 100644
--- a/kafka/producer/kafka.py
+++ b/kafka/producer/kafka.py
@@ -283,7 +283,8 @@ class KafkaProducer(object):
if self.config['compression_type'] == 'lz4':
assert self.config['api_version'] >= (0, 8, 2), 'LZ4 Requires >= Kafka 0.8.2 Brokers'
- self._accumulator = RecordAccumulator(**self.config)
+ message_version = 1 if self.config['api_version'] >= (0, 10) else 0
+ self._accumulator = RecordAccumulator(message_version=message_version, **self.config)
self._metadata = client.cluster
self._sender = Sender(client, self._metadata, self._accumulator,
**self.config)
diff --git a/kafka/producer/sender.py b/kafka/producer/sender.py
index 9c36c9b..f10c34c 100644
--- a/kafka/producer/sender.py
+++ b/kafka/producer/sender.py
@@ -174,11 +174,16 @@ class Sender(threading.Thread):
for batch in batches])
for topic, partitions in response.topics:
- for partition, error_code, offset in partitions:
+ for partition_info in partitions:
+ if response.API_VERSION < 2:
+ partition, error_code, offset = partition_info
+ ts = None
+ else:
+ partition, error_code, offset, ts = partition_info
tp = TopicPartition(topic, partition)
error = Errors.for_code(error_code)
batch = batches_by_partition[tp]
- self._complete_batch(batch, error, offset)
+ self._complete_batch(batch, error, offset, ts)
else:
# this is the acks = 0 case, just complete all requests
@@ -258,7 +263,12 @@ class Sender(threading.Thread):
buf = batch.records.buffer()
produce_records_by_partition[topic][partition] = buf
- version = 1 if self.config['api_version'] >= (0, 9) else 0
+ if self.config['api_version'] >= (0, 10):
+ version = 2
+ elif self.config['api_version'] == (0, 9):
+ version = 1
+ else:
+ version = 0
return ProduceRequest[version](
required_acks=acks,
timeout=timeout,