Skip to content

Commit e2e85eb

Browse files
authored
Do not return control batch records
Control messages are used to enable transactions in Kafka and are generated by the broker. Clients should not return control batches (ie. those with this bit set) to applications. (since 0.11.0.0)
1 parent 7ac6c6e commit e2e85eb

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

kafka/consumer/fetcher.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,13 @@ def _unpack_message_set(self, tp, records):
464464
except AttributeError:
465465
pass
466466

467+
# Control messages are used to enable transactions in Kafka and are generated by the
468+
# broker. Clients should not return control batches (ie. those with this bit set) to
469+
# applications. (since 0.11.0.0)
470+
if getattr(batch, "is_control_batch", False):
471+
batch = records.next_batch()
472+
continue
473+
467474
for record in batch:
468475
key_size = len(record.key) if record.key is not None else -1
469476
value_size = len(record.value) if record.value is not None else -1

0 commit comments

Comments
 (0)