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.public class ChangeEventQueue<T> extends Object implements ChangeEventQueueMetrics
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 #producerFailure 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.
| Modifier and Type | Class and Description |
|---|---|
static class |
ChangeEventQueue.Builder<T> |
| Modifier and Type | Field and Description |
|---|---|
private static org.slf4j.Logger |
LOGGER |
private Supplier<LoggingContext.PreviousContext> |
loggingContextSupplier |
private int |
maxBatchSize |
private int |
maxQueueSize |
private Metronome |
metronome |
private Duration |
pollInterval |
private RuntimeException |
producerException |
private BlockingQueue<T> |
queue |
| Modifier | Constructor and Description |
|---|---|
private |
ChangeEventQueue(Duration pollInterval,
int maxQueueSize,
int maxBatchSize,
Supplier<LoggingContext.PreviousContext> loggingContextSupplier) |
| Modifier and Type | Method and Description |
|---|---|
void |
enqueue(T record)
Enqueues a record so that it can be obtained via
poll(). |
List<T> |
poll()
Returns the next batch of elements from this queue.
|
void |
producerException(RuntimeException producerException) |
int |
remainingCapacity() |
private void |
throwProducerExceptionIfPresent() |
int |
totalCapacity() |
private static final org.slf4j.Logger LOGGER
private final Duration pollInterval
private final int maxBatchSize
private final int maxQueueSize
private final BlockingQueue<T> queue
private final Metronome metronome
private final Supplier<LoggingContext.PreviousContext> loggingContextSupplier
private volatile RuntimeException producerException
private ChangeEventQueue(Duration pollInterval, int maxQueueSize, int maxBatchSize, Supplier<LoggingContext.PreviousContext> loggingContextSupplier)
public void enqueue(T record) throws InterruptedException
poll(). This method
will block if the queue is full.record - the record to be enqueuedInterruptedException - if this thread has been interruptedpublic List<T> poll() throws InterruptedException
InterruptedException - if this thread has been interrupted while waiting for more
elements to arrivepublic void producerException(RuntimeException producerException)
private void throwProducerExceptionIfPresent()
public int totalCapacity()
totalCapacity in interface ChangeEventQueueMetricspublic int remainingCapacity()
remainingCapacity in interface ChangeEventQueueMetricsCopyright © 2020 JBoss by Red Hat. All rights reserved.