Skip to content

Commit 95856f0

Browse files
committed
KIP-91: KafkaProducer delivery_timeout_ms
1 parent 81a7540 commit 95856f0

File tree

4 files changed

+426
-207
lines changed

4 files changed

+426
-207
lines changed

kafka/producer/kafka.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,16 @@ class KafkaProducer(object):
106106
defaults to be suitable. If the values are set to something
107107
incompatible with the idempotent producer, a KafkaConfigurationError
108108
will be raised.
109-
109+
delivery_timeout_ms (float): An upper bound on the time to report success
110+
or failure after producer.send() returns. This limits the total time
111+
that a record will be delayed prior to sending, the time to await
112+
acknowledgement from the broker (if expected), and the time allowed
113+
for retriable send failures. The producer may report failure to send
114+
a record earlier than this config if either an unrecoverable error is
115+
encountered, the retries have been exhausted, or the record is added
116+
to a batch which reached an earlier delivery expiration deadline.
117+
The value of this config should be greater than or equal to the
118+
sum of (request_timeout_ms + linger_ms). Default: 120000.
110119
acks (0, 1, 'all'): The number of acknowledgments the producer requires
111120
the leader to have received before considering a request complete.
112121
This controls the durability of records that are sent. The
@@ -142,8 +151,12 @@ class KafkaProducer(object):
142151
potentially change the ordering of records because if two batches
143152
are sent to a single partition, and the first fails and is retried
144153
but the second succeeds, then the records in the second batch may
145-
appear first.
146-
Default: 0.
154+
appear first. Note additionally that produce requests will be
155+
failed before the number of retries has been exhausted if the timeout
156+
configured by delivery_timeout_ms expires first before successful
157+
acknowledgement. Users should generally prefer to leave this config
158+
unset and instead use delivery_timeout_ms to control retry behavior.
159+
Default: 2147483647 (java max int).
147160
batch_size (int): Requests sent to brokers will contain multiple
148161
batches, one for each partition with data available to be sent.
149162
A small batch size will make batching less common and may reduce
@@ -320,10 +333,11 @@ class KafkaProducer(object):
320333
'enable_idempotence': False,
321334
'transactional_id': None,
322335
'transaction_timeout_ms': 60000,
336+
'delivery_timeout_ms': 120000,
323337
'acks': 1,
324338
'bootstrap_topics_filter': set(),
325339
'compression_type': None,
326-
'retries': 0,
340+
'retries': 2147483647,
327341
'batch_size': 16384,
328342
'linger_ms': 0,
329343
'partitioner': DefaultPartitioner(),

0 commit comments

Comments
 (0)