public class DefaultConnection extends java.lang.Object implements Connection
| Constructor and Description |
|---|
DefaultConnection(BrokerAddress brokerAddress,
java.lang.String clientId,
int bufferSize,
int soTimeout,
int minBytes,
int maxWait) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the connection to the broker.
|
Result<java.lang.Void> |
commitOffsetsForConsumer(java.lang.String consumerId,
java.util.Map<Partition,java.lang.Long> offsets)
Update offsets in the native Kafka offset management system.
|
Result<KafkaMessageBatch> |
fetch(FetchRequest... requests)
Fetche data from Kafka.
|
Result<java.lang.Long> |
fetchInitialOffset(long referenceTime,
Partition... partitions)
Fetch an actual offset in the partition, immediately before the given reference time,
or the smallest and largest value, respectively, if the special values -1
(
OffsetRequest.LatestTime()) and -2 (OffsetRequest.LatestTime())
are used . |
Result<java.lang.Long> |
fetchStoredOffsetsForConsumer(java.lang.String consumerId,
Partition... partitions)
Fetch offsets from the native Kafka offset management system.
|
Result<BrokerAddress> |
findLeaders(java.lang.String... topics)
Deprecated.
|
BrokerAddress |
getBrokerAddress()
The broker address for this consumer
|
public DefaultConnection(BrokerAddress brokerAddress, java.lang.String clientId, int bufferSize, int soTimeout, int minBytes, int maxWait)
public BrokerAddress getBrokerAddress()
ConnectiongetBrokerAddress in interface ConnectionConnection.getBrokerAddress()public void close()
Connectionclose in interface Connectionpublic Result<KafkaMessageBatch> fetch(FetchRequest... requests) throws ConsumerException
fetch in interface Connectionrequests - a list of fetch operationsConsumerException - the ConsumerException if any underlying errorpublic Result<java.lang.Long> fetchStoredOffsetsForConsumer(java.lang.String consumerId, Partition... partitions) throws ConsumerException
ConnectionfetchStoredOffsetsForConsumer in interface ConnectionconsumerId - the id of the consumerpartitions - the list of partitions whose offsets are queried forResult in case of successConsumerException - the ConsumerException if any underlying errorpublic Result<java.lang.Long> fetchInitialOffset(long referenceTime, Partition... partitions) throws ConsumerException
ConnectionOffsetRequest.LatestTime()) and -2 (OffsetRequest.LatestTime())
are used . To be used to position the initial offset of a read operation.fetchInitialOffset in interface ConnectionreferenceTime - The returned values will be before this time, if they exist. The special
values -2 (OffsetRequest.LatestTime()) and -1 (OffsetRequest.LatestTime()) are supported.partitions - the offsets, indexed by PartitionResult in case of successConsumerException - the ConsumerException if any underlying errorConnection.fetchInitialOffset(long, Partition...)public Result<java.lang.Void> commitOffsetsForConsumer(java.lang.String consumerId, java.util.Map<Partition,java.lang.Long> offsets) throws ConsumerException
ConnectioncommitOffsetsForConsumer in interface ConnectionconsumerId - the id of the consumeroffsets - the offsets, indexed by PartitionResult in case of successConsumerException - the ConsumerException if any underlying error@Deprecated public Result<BrokerAddress> findLeaders(java.lang.String... topics) throws ConsumerException
ConnectionfindLeaders in interface Connectiontopics - the topics whose partitions we query forPartitionConsumerException - the ConsumerException if any underlying errorConnection.findLeaders(String...)