Spring Integration Kafka Support

org.springframework.integration.kafka.core
Interface Connection

All Known Implementing Classes:
DefaultConnection

public interface Connection

A connection to a Kafka broker.

Author:
Marius Bogoevici

Method Summary
 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
 

Method Detail

fetch

Result<KafkaMessageBatch> fetch(FetchRequest... fetchRequests)
                                throws ConsumerException
Fetch data from a Kafka broker.

Parameters:
fetchRequests - a list of fetch operations
Returns:
message batches, indexed by partition
Throws:
ConsumerException - the ConsumerException if any underlying error

fetchInitialOffset

Result<java.lang.Long> fetchInitialOffset(long referenceTime,
                                          Partition... partitions)
                                          throws ConsumerException
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 . To be used to position the initial offset of a read operation.

Parameters:
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
Returns:
any errors, an empty Result in case of success
Throws:
ConsumerException - the ConsumerException if any underlying error

fetchStoredOffsetsForConsumer

Result<java.lang.Long> fetchStoredOffsetsForConsumer(java.lang.String consumerId,
                                                     Partition... partitions)
                                                     throws ConsumerException
Fetch offsets from the native Kafka offset management system.

Parameters:
consumerId - the id of the consumer
partitions - the list of partitions whose offsets are queried for
Returns:
any errors, an empty Result in case of success
Throws:
ConsumerException - the ConsumerException if any underlying error

commitOffsetsForConsumer

Result<java.lang.Void> commitOffsetsForConsumer(java.lang.String consumerId,
                                                java.util.Map<Partition,java.lang.Long> offsets)
                                                throws ConsumerException
Update offsets in the native Kafka offset management system.

Parameters:
consumerId - the id of the consumer
offsets - the offsets, indexed by Partition
Returns:
any errors, an empty Result in case of success
Throws:
ConsumerException - the ConsumerException if any underlying error

findLeaders

Result<BrokerAddress> findLeaders(java.lang.String... topics)
                                  throws ConsumerException
Retrieve the leader broker addresses for all the partitions in the given topics.

Parameters:
topics - the topics whose partitions we query for
Returns:
broker addresses, indexed by Partition
Throws:
ConsumerException - the ConsumerException if any underlying error

getBrokerAddress

BrokerAddress getBrokerAddress()
The broker address for this consumer

Returns:
broker address

close

void close()
Closes the connection to the broker. No further operations are permitted.


Spring Integration Kafka Support