Class ChangeEventQueue<T>

  • Type Parameters:
    T - the type of events in this queue. Usually SourceRecord is used, but in cases where additional metadata must be passed from producers to the consumer, a custom type wrapping source records may be used.
    All Implemented Interfaces:
    ChangeEventQueueMetrics

    @ThreadSafe
    public class ChangeEventQueue<T>
    extends Object
    implements ChangeEventQueueMetrics
    A queue which serves as handover point between producer threads (e.g. MySQL's binlog reader thread) and the Kafka Connect polling loop.

    The queue is configurable in different aspects, e.g. its maximum size and the time to sleep (block) between two subsequent poll calls. See the ChangeEventQueue.Builder for the different options. The queue applies back-pressure semantics, i.e. if it holds the maximum number of elements, subsequent calls to enqueue(Object) will block until elements have been removed from the queue.

    If an exception occurs on the producer side, the producer should make that exception known by calling producerException(RuntimeException) before stopping its operation. Upon the next call to poll(), that exception will be raised, causing Kafka Connect to stop the connector and mark it as FAILED.

    Author:
    Gunnar Morling
    • Field Detail

      • LOGGER

        private static final org.slf4j.Logger LOGGER
      • pollInterval

        private final Duration pollInterval
      • maxBatchSize

        private final int maxBatchSize
      • maxQueueSize

        private final int maxQueueSize
      • maxQueueSizeInBytes

        private final long maxQueueSizeInBytes
      • queue

        private final Queue<T> queue
      • sizeInBytesQueue

        private final Queue<Long> sizeInBytesQueue
      • currentQueueSizeInBytes

        private long currentQueueSizeInBytes
      • buffering

        private boolean buffering
      • bufferedEvent

        private T bufferedEvent
    • Constructor Detail