public interface Connection
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... fetchRequests)
Fetch data from a Kafka broker.
|
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)
Retrieve the leader broker addresses for all the partitions in the given topics.
|
BrokerAddress |
getBrokerAddress()
The broker address for this consumer
|
Result<KafkaMessageBatch> fetch(FetchRequest... fetchRequests) throws ConsumerException
fetchRequests
- a list of fetch operationsConsumerException
- the ConsumerException if any underlying errorResult<java.lang.Long> fetchInitialOffset(long referenceTime, Partition... partitions) throws ConsumerException
OffsetRequest.LatestTime()
) and -2 (OffsetRequest.LatestTime()
)
are used . To be used to position the initial offset of a read operation.referenceTime
- 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 Partition
Result
in case of successConsumerException
- the ConsumerException if any underlying errorResult<java.lang.Long> fetchStoredOffsetsForConsumer(java.lang.String consumerId, Partition... partitions) throws ConsumerException
consumerId
- the id of the consumerpartitions
- the list of partitions whose offsets are queried forResult
in case of successConsumerException
- the ConsumerException if any underlying errorResult<java.lang.Void> commitOffsetsForConsumer(java.lang.String consumerId, java.util.Map<Partition,java.lang.Long> offsets) throws ConsumerException
consumerId
- the id of the consumeroffsets
- the offsets, indexed by Partition
Result
in case of successConsumerException
- the ConsumerException if any underlying errorResult<BrokerAddress> findLeaders(java.lang.String... topics) throws ConsumerException
topics
- the topics whose partitions we query forPartition
ConsumerException
- the ConsumerException if any underlying errorBrokerAddress getBrokerAddress()
void close()