Class ChangeEventQueue<T extends Sizeable>

java.lang.Object
io.debezium.connector.base.ChangeEventQueue<T>
Type Parameters:
T - the type of events in this queue. Usually Sizeable is used, but in cases where additional metadata must be passed from producers to the consumer, a custom type extending source records may be used.
All Implemented Interfaces:
ChangeEventQueueMetrics

@ThreadSafe public class ChangeEventQueue<T extends Sizeable> 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(T) 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 Details

    • 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
    • lock

      private final Lock lock
    • isFull

      private final Condition isFull
    • isNotFull

      private final Condition isNotFull
    • queue

      private final Queue<T extends Sizeable> queue
    • loggingContextSupplier

      private final Supplier<LoggingContext.PreviousContext> loggingContextSupplier
    • sizeInBytesQueue

      private final Queue<Long> sizeInBytesQueue
    • currentQueueSizeInBytes

      private long currentQueueSizeInBytes
    • buffering

      private boolean buffering
    • bufferedEvent

      private T extends Sizeable bufferedEvent
    • producerException

      private volatile RuntimeException producerException
  • Constructor Details

  • Method Details