java.lang.Object
org.apache.kafka.clients.producer.internals.Sender
All Implemented Interfaces:
Runnable

public class Sender extends Object implements Runnable
The background thread that handles the sending of produce requests to the Kafka cluster. This thread makes metadata requests to renew its view of the cluster and then sends produce requests to the appropriate nodes.
  • Constructor Details

    • Sender

      public Sender(org.apache.kafka.common.utils.LogContext logContext, org.apache.kafka.clients.KafkaClient client, ProducerMetadata metadata, RecordAccumulator accumulator, boolean guaranteeMessageOrder, int maxRequestSize, short acks, int retries, SenderMetricsRegistry metricsRegistry, org.apache.kafka.common.utils.Time time, int requestTimeoutMs, long retryBackoffMs, TransactionManager transactionManager, org.apache.kafka.clients.ApiVersions apiVersions)
  • Method Details

    • inFlightBatches

      public List<ProducerBatch> inFlightBatches(org.apache.kafka.common.TopicPartition tp)
    • addToInflightBatches

      public void addToInflightBatches(Map<Integer,List<ProducerBatch>> batches)
    • run

      public void run()
      The main run loop for the sender thread
      Specified by:
      run in interface Runnable
    • initiateClose

      public void initiateClose()
      Start closing the sender (won't actually complete until all data is sent out)
    • forceClose

      public void forceClose()
      Closes the sender without sending out any pending messages.
    • isRunning

      public boolean isRunning()
    • wakeup

      public void wakeup()
      Wake up the selector associated with this send thread
    • throttleTimeSensor

      public static org.apache.kafka.common.metrics.Sensor throttleTimeSensor(SenderMetricsRegistry metrics)