Sender

Sender is thread of execution that handles the sending of produce requests to a Kafka cluster.

Sender.png
Figure 1. Sender and KafkaProducer

Sender is created exclusively when KafkaProducer is created.

Sender is started under the name kafka-producer-network-thread | [clientId] when KafkaProducer is created.

Table 1. Sender’s Internal Properties (e.g. Registries and Counters)
Name Description

running

Flag that controls whether run should finish or not

sendProduceRequests Internal Method

void sendProduceRequests(Map<Integer, List<ProducerBatch>> collated, long now)

sendProduceRequests…​FIXME

Note
sendProduceRequests is used exclusively when Sender sendProducerData.

sendProduceRequest Internal Method

void sendProduceRequest(
  long now,
  int destination,
  short acks,
  int timeout,
  List<ProducerBatch> batches)

sendProduceRequest…​FIXME

Note
sendProduceRequest is used exclusively when Sender sendProduceRequests.

sendProducerData Internal Method

long sendProducerData(long now)

sendProducerData…​FIXME

Note
sendProducerData is used exclusively when Sender runs a single iteration of sending.

Running Single Iteration of Sending — run Method

void run(long now)

run…​FIXME

Note
run is used exclusively when Sender is started (as a thread of execution).

Starting Thread of Execution — run Method (of Java’s Runnable)

void run()
Note
run is a part of java.lang.Runnable that is executed when the thread is started.

run first prints out the following DEBUG message to the logs:

Starting Kafka producer I/O thread.

run keeps running (with the current time in milliseconds) until running flag is turned off.

run…​FIXME

Creating Sender Instance

Sender takes the following when created:

  • LogContext

  • KafkaClient

  • Metadata

  • RecordAccumulator

  • guaranteeMessageOrder flag

  • maxRequestSize

  • acks

  • The number of retries

  • SenderMetricsRegistry

  • Time

  • requestTimeout

  • retryBackoffMs

  • TransactionManager

  • ApiVersions

Sender initializes the internal registries and counters.

results matching ""

    No results matching ""