Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

So, this KIP try to reach the goal we can change the max.block.ms to wanted smaller value without worry about the metadata's fetch.

Public Interfaces

No public interface changed. Just change the inner implement of private method:

org.apache.kafka.clients.producer.KafkaProducer#doSend

...

The changes can refer to the example PR:  https://github.com/apache/kafka/pull/13335/files

Add two configures with tiny code changes related which control the timeout in KafkaProducer#send

1. Two configures added

Producer's configure.

configure item.

default value


includeWaitTimeOnMetadataInMaxBlockTime

max.block.ms.include.metadata

false

maxWaitTimeMsOnMetadata

max.block.metadata.ms

<max.block.ms

...

if we need N (2<N<5) seconds for metadata's fetch, we will send record to test producer with different configures.

Cases to send record.\Configures

max.block.ms

includeWaitTimeOnMetadataInMaxBlockTime(max.block.ms.include.metadata)

maxWaitTimeMsOnMetadata(max.block.metadata.ms)

case 1 success

10 seconds

default value: false (no set)

default value: 60 seconds (no set)

case 2 fail to send

1 seconds

default value: false (no set)

default value: 60 seconds (no set)

case 3 success 

10 seconds

true

default value: 60 seconds (no set)

case 4 success

1 seconds

true

5 seconds

case 5 fail to send

1 seconds

true

1 seconds

Case 2 and case 5 will fail to send records. Others are success one.

Rejected Alternatives

Alternative 1:

...