public final class KafkaConsumer extends Object implements Closeable
| Modifier and Type | Field and Description |
|---|---|
static int |
BUFFER_SIZE_BYTES |
static long |
EARLIEST_OFFSET |
static long |
LATEST_OFFSET |
static int |
TIMEOUT_MS |
| Constructor and Description |
|---|
KafkaConsumer(List<LoggingConfiguration.KafkaHost> seedBrokers,
String topic,
int partition,
int fetchTimeoutMs)
Creates a KafkaConsumer with initial set of seed brokers, topic and partition.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
int |
fetchMessages(long offset,
Callback callback)
Fetches Kafka messages from an offset.
|
long |
fetchOffsetBefore(long timeMillis)
Fetch offset before given time.
|
public static final long EARLIEST_OFFSET
public static final long LATEST_OFFSET
public static final int BUFFER_SIZE_BYTES
public static final int TIMEOUT_MS
public KafkaConsumer(List<LoggingConfiguration.KafkaHost> seedBrokers, String topic, int partition, int fetchTimeoutMs)
seedBrokers - list of seed brokerstopic - Kafka topic to subscribe topartition - topic partition to subscribe tofetchTimeoutMs - timeout for a Kafka fetch callpublic int fetchMessages(long offset,
Callback callback)
throws kafka.common.OffsetOutOfRangeException
offset - message offset to start.callback - callback to handle the messages fetched.kafka.common.OffsetOutOfRangeExceptionpublic long fetchOffsetBefore(long timeMillis)
timeMillis - offset to fetch before timeMillis.public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionCopyright © 2015 Cask Data, Inc. Licensed under the Apache License, Version 2.0.